Expand my Community achievements bar.

SOLVED

When can I call setUserRole on a CollectionNode?

Avatar

Level 3
Hi again,

I'd like to call setUserRole on a CollectionNode. Can I do
that right when the CollectionNode gets created (right now that's
inside my SharedModel's subscribe method)? I don't think it does
because I get a RTE if I try:

TypeError: Error #1009: Cannot access a property or method of
a null object reference.

at
com.adobe.rtc.sharedModel::CollectionNode/setUserRole()[C:\work\main\connect\cocomo\src\com\adobe\rtc\sharedModel\CollectionNode.as:429]



It's _messageManager that is null.



I have a feeling that I should wait until I get a
SYNCHRONIZATION_CHANGE event before I try setUserRole because
before the node has synced it does not yet know anything about its
own state and access permissions, is that correct?



Regards,



Stefan



1 Accepted Solution

Avatar

Correct answer by
Level 3
Excellent, just what I was looking for.



thanks.

View solution in original post

2 Replies

Avatar

Former Community Member
Hi,



I am adding a small code for showing collection Node creation
and setUserRole. The important thing to note is you need to call
collectionNode.subscribe() after creating before you can call
collectionNode.setUserRole else you will get that RTE.



Here is the code below for reference.



Thanks

Hironmay Basu



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

<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:rtc="AfcsNameSpace">

<mx:Script>

<![CDATA[

import com.adobe.rtc.sharedModel.CollectionNode;

import com.adobe.rtc.messaging.UserRoles;







private var collectionNode:CollectionNode ;

private function onCreationComplete():void

{

collectionNode = new CollectionNode();

collectionNode.sharedID = "sharedModel4" ;

collectionNode.connectSession = cSession ;

collectionNode.subscribe();


collectionNode.setUserRole(cSession.userManager.myUserID,UserRoles.PUBLISHER);

}







]]>

</mx:Script>

<rtc:AdobeHSAuthenticator id="auth" userName="Your
UserName" password="Your Password"/>

<rtc:ConnectSessionContainer id="cSession"
authenticator="{auth}" roomURL="Your Room Url"
creationComplete="onCreationComplete()" >

</rtc:ConnectSessionContainer>

</mx:Application>

Avatar

Correct answer by
Level 3
Excellent, just what I was looking for.



thanks.