Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

BinaryPublisher throwing error on line 113 in BinaryPublisher.as

Avatar

Former Community Member

Hi,

I am trying to use BinaryPublisher and somehow it is throwing me an error on line 113 inside of the BinaryPublisher.as !

So I looked up the src (for flash 10.3) com.adobe.rtc.collaboration.BinaryPublisher.as and this is the line with the error:

_uploadFileDescriptor.id = p_itemID;

And this is how I am calling the binarypublisher publish function:

_binaryPublisher.publish("test.bmp",p_event.currentTarget.bytes,UIDUtil.createUID(),"application/x-shockwave-flash");

So I am pretty sure that p_itemID is not null because UIDUtil.createUID() is creating a unique ID string.

Another thing I am confused about is, that when I take a look in the Debugger at the binaryPublisher._userManager it is null. Even though I am doing this here:

if (connectSession.isSynchronized){

     _binaryPublisher.connectSession = connectSession;

}

Can anyone help me or give me a hint. I am kind of lost here.

4 Replies

Avatar

Former Community Member

Okay so I kept on messing with the problem and the only fix I could come up for myself is the following. I just create a BinaryPublisherFix Class which extends BinaryPublisher. And in that class I am just overriding the publish function and pretty much just getting rid of all the null values.

So here is my solution:

package components

{

    import com.adobe.rtc.collaboration.BinaryPublisher;

    import com.adobe.rtc.messaging.NodeConfiguration;

    import com.adobe.rtc.messaging.UserRoles;

    import com.adobe.rtc.sharedManagers.FileManager;

    import com.adobe.rtc.sharedManagers.UserManager;

    import com.adobe.rtc.sharedManagers.descriptors.FileDescriptor;

   

    import flash.utils.ByteArray;

   

    public class BinaryPublisherFix extends BinaryPublisher

    {

       

        public function BinaryPublisherFix()

        {

            super();

        }

       

        public function set userManager(p_userManager:UserManager):void{ this._userManager = p_userManager };

        public function set fileManager(p_fileManager:FileManager):void{ this._fileManager = p_fileManager };

       

        override public function publish(p_fileName:String, p_fileData:ByteArray, p_itemID:String=null, p_contentType:String="application/octet-stream"):void

        {       

            progressInterval = progressInterval;

            subscribe();

           

            if (!_fileManager.isGroupDefined("fileShare") && _fileManager.getUserRole(_userManager.myUserID, "fileShare") == UserRoles.OWNER)

            {

                //Create a new node with a new groupid.

                var nodeConfig:NodeConfiguration=new NodeConfiguration();

                nodeConfig.sessionDependentItems=false;

                //Specifies whether files in the pod should be deleted as the session ends.

                createAndUseGroup("fileShare", nodeConfig);

            }

            else

            {

                //otherwise, use assigned groupid

                if (_fileManager.isGroupDefined("fileShare"))

                {

                    groupName="fileShare";

                }

            }

           

            _fileName = p_fileName;

            _fileData = p_fileData;

            _contentType = p_contentType;

            _uploadFileDescriptor = new FileDescriptor();

            _uploadFileDescriptor.id = p_itemID;           

            _uploadFileDescriptor.submitterID = _userManager.myUserID;

            _uploadFileID = p_itemID;

           

            if(_fileName != null && _fileData.length > 0)

                announceIntentionPublish(_fileName, _fileData.length);

        }

    }

}

and this is the steps on creating my BinaryPublisherFix Object:

protected var _binaryPublisher:BinaryPublisherFix = new BinaryPublisherFix();

_binaryPublisher.connectSession = connectSession;

_binaryPublisher.userManager = connectSession.userManager;

_binaryPublisher.fileManager = connectSession.fileManager;

Well it ACTUALLY WORKS! My question is why do I have to do that ????

And yes I know the code can be more optimized and I have some hard coded stuff in there too. But I was just trying to get a fix as quick as possible and as soon as I figured it out I wanted to post it in here. So maybe one of the Emplayees or so can tell me what I maybe did wrong in the first place or why do I have to use that workaround.

Thank you

Avatar

Employee

Somebody in our team doesn't like to check for null

We'll try to integrate your changes and they should be available in the next SDK update.

Avatar

Former Community Member

Thanks for answering. Glad I could help I guess

Just so I understand. Am I the only one using BinaryPublisher? Or did that error occur because of me missusing it in some way or not really initializing an instance of that class correctly?

Is there maybe another way to pass the connectSession? Or whatever ?

Because all it is at the end, is that like you said a few variables are just null even though all the objects are available.

Thanks for your answer.

Avatar

Employee

Hi,

BinaryPublisher extends an API called FilePublisher. The userManager is set in the FilePublisher, and I did verify that it gets set. Are you subscribing after you set your connectsession ?, I am guessing your workflow is messing up your app...

Thanks

Arun