Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

CustomField confusion

Avatar

Level 3

CustomFields don't seem to act as I expected. I have a few customFields defined. The order I log into the room determines the custom field values I get in the UserCollection.

I would expect that a customField for a user value would persist with that user. Is that not the case?

Here's my use case. I setCustomUserField in the creationComplete for each connectSessionContainer that logs into my room. If I am the first user into a room the customFields populate fine. If I'm the second person into the room the customFields for me appear, but not the first user. However user2's customfields appear with user1's in the user 1 instance.

Here's what seems to be happening. A customField propagate to all connected users, but isn't delivered when a new user connects. So if I"m the last one that enters a room all I see is my own customField. Is this the way it's intended to work or am I missing something?

4 Replies

Avatar

Employee

Hi,

I ran the CustomField app in the sampleApps inside the SDK. I was able to see customField of all the users irrespective of the order of their login. Can you refer the code in the SampleApps for what might be going wrong. If your issue is still not fixed and can you post your code.

Thanks

Arun

Avatar

Level 3

Here's what I am doing. I'm creating a customField for each user on ConnectSessionContainer Complete.

connectSession.userManager.setCustomUserField( connectSession.userManager.myUserID, "hasAudio", Capabilities.hasAudio );

connectSession.userManager.setCustomUserField( connectSession.userManager.myUserID, "hasVideo", Capabilities.hasVideoEncoder );

I add a hasAudio and hasVideo field. I populate the customFields with values from the Capabilitites Class. It publishes these properties to everone currently logged into the room. And I display icons in a renderer depending on the values. If I login to the room after someone is already there. The customFields properties of the UserDescription objects in the UserManager.UserColleciton are all empty no customFields appear even if they are there for other people.

What am I missing?

John

Avatar

Employee

Hi,

I tried the scenario you mentioned. I have even attached the code. It seems to work.

At this point I suspect your itemRenderer , Hopefully I am not missing something.

Thanks

Arun

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:authentication="com.adobe.rtc.authentication.*" xmlns:session="com.adobe.rtc.session.*" xmlns:pods="com.adobe.rtc.pods.*" xmlns:collabs="com.adobe.rtc.collaboration.*" xmlns:subc="com.adobe.rtc.collaboration.screenShareSubscriberClasses.*">
     <mx:Script>
          <![CDATA[
               import com.adobe.rtc.events.UserEvent;
               import com.adobe.rtc.messaging.UserRoles;
               import com.adobe.rtc.sharedManagers.UserManager;
               private var _userManager:UserManager ;
               
               private function onCreationComplete():void
               {
                    // adding the event handler for the custom field register
                    // we can resgiter or add custom field also from the dev console
                    //when the field gets registered , we should then set the value on it
                    _userManager = cSession.userManager ;
                    _userManager.addEventListener(UserEvent.CUSTOM_FIELD_REGISTER, onCustomFieldRegister);
                    
                    // registering the field if it doesnt exist. Best way to do is also through dev console
                    // only the hosts can register the field
                    if (!_userManager.isCustomFieldDefined('hasAudio') && _userManager.myUserRole == UserRoles.OWNER) {
                         _userManager.registerCustomUserField('hasAudio');
                         _userManager.registerCustomUserField('hasVideo');
                    }else if ( _userManager.isCustomFieldDefined('hasVideo')) {
                         _userManager.setCustomUserField( _userManager.myUserID, "hasAudio", Capabilities.hasAudio );
                         _userManager.setCustomUserField( _userManager.myUserID, "hasVideo", Capabilities.hasVideoEncoder );
                    }
               }
               
               private function onCustomFieldRegister(p_event:UserEvent):void
               {     
                    //setting the custom field if its registered already
                    // you can set the value depending on your role on the custom field node initially set by user , by default its 50 or above
                    // You can change these from the dev console
                    if ( _userManager.isCustomFieldDefined(p_event.customFieldName) && p_event.customFieldName== "hasAudio") {
                         _userManager.setCustomUserField( _userManager.myUserID, "hasAudio", Capabilities.hasAudio );
                    }
                    
                    if ( _userManager.isCustomFieldDefined(p_event.customFieldName) && p_event.customFieldName== "hasVideo") {
                         _userManager.setCustomUserField( _userManager.myUserID, "hasVideo", Capabilities.hasVideoEncoder );
                    }

               }
               
               
               private function scoreAudioFunction(item:Object,column:DataGridColumn):String
               {
                    // if you want to show it as a label in datagrid or list, you need to use label function
                    //directly using "customField.fieldname" in dataField will not work
                    return item.customFields['hasAudio'] ;
               }
               
               private function scoreVideoFunction(item:Object,column:DataGridColumn):String
               {
                    // if you want to show it as a label in datagrid or list, you need to use label function
                    //directly using "customField.fieldname" in dataField will not work
                    return item.customFields['hasVideo'] ;
               }

               
               private function onDeleteClick(p_evt:MouseEvent):void
               {
                    /// You can delete the custom field only if you are an owner
                    if ( _userManager.isCustomFieldDefined('score') && _userManager.myUserRole == UserRoles.OWNER) {
                         _userManager.deleteCustomUserField('score');
                    }
               }
               
          ]]>
     </mx:Script>
     
     <session:ConnectSessionContainer id="cSession" roomURL="" creationComplete="onCreationComplete()">
          <session:authenticator>
               <authentication:AdobeHSAuthenticator userName="" password="" />
          </session:authenticator>
          <mx:VBox width="400" height="400" >
               <mx:DataGrid id="datag" dataProvider="{cSession.userManager.userCollection}">
                    <mx:columns>
                         <mx:DataGridColumn id="c1" headerText="Name" dataField="displayName" />
                         <mx:DataGridColumn id="c2" headerText="hasAudio" dataField="customFields['hasAudio']" labelFunction="scoreAudioFunction" />
                         <mx:DataGridColumn id="c3" headerText="hasVideo" dataField="customFields['hasVideo']" labelFunction="scoreVideoFunction" />
                    </mx:columns>
               </mx:DataGrid>
               <mx:Button id="deleteCustomField" click="onDeleteClick(event)" label="Delete Custom Field" height="30" />
          </mx:VBox>
     </session:ConnectSessionContainer>
</mx:Application>

Avatar

Level 3

Now I'm really confused.

I've created the test app to demonstrate.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

xmlns:rtc="AfcsNameSpace"

layout="absolute">

<rtc:AdobeHSAuthenticator id="auth" username="" password=""  />

<rtc:ConnectSessionContainer id="connectSession"

width="100%"

height="100%"

authenticator="{ auth }"

roomURL="

creationComplete="onSessionCreationComplete()"

>

<mx:DataGrid id="datag" dataProvider="{connectSession.userManager.userCollection}">

                    <mx:columns>

                         <mx:DataGridColumn id="c1" headerText="Name" dataField="displayName" />

                         <mx:DataGridColumn id="c2" headerText="hasAudio" dataField="customFields['hasAudio']" labelFunction="audioFunction" />

                         <mx:DataGridColumn id="c3" headerText="hasVideo" dataField="customFields['hasVideo']" labelFunction="videoFunction" />

                    </mx:columns>

               </mx:DataGrid>

</rtc:ConnectSessionContainer>

<mx:Script>

<![CDATA[

import com.adobe.rtc.sharedManagers.UserManager;

import mx.controls.Alert;

protected function onSessionCreationComplete():void

{

/**

* Check for audio capabilitites

*/

if ( connectSession.userManager.isCustomFieldDefined( "hasAudio") )

{

connectSession.userManager.setCustomUserField( connectSession.userManager.myUserID, "hasAudio", Capabilities.hasAudio );

connectSession.userManager.setCustomUserField( connectSession.userManager.myUserID, "hasVideo", Capabilities.hasVideoEncoder );

}else

Alert.show("no Custom Fields Defined");

}

protected function audioFunction( item:Object,column:DataGridColumn ):String

{

return item.customFields['hasAudio'] ;

}

protected function videoFunction( item:Object,column:DataGridColumn ):String

{

return item.customFields['hasVideo'] ;

}

]]>

</mx:Script>

</mx:Application>

I've predefined the customFields through the console as most users won't have rights to.

If I run this app, I see the proper values in the dataGrid but if I place a break point in onSessionCreationComplete or even in audioFunction and inspect the variables in the debugger it has empty customFields for everone who is already in the room. If they login after me their customFields Object is populated properly in the debugger.

I'm using userdescription.customFields.hasAudio in an if statement to show the icon. So of course the statement fails for the empty customFields Objects.

What's the funkiness with the labelFunction is that workaround related?