Expand my Community achievements bar.

How can I use the same session for different components acroos application ?

Avatar

Level 1

I am trying to include the components(chat, filesharing, whitboard) in different parts of my application. User should be able to access any of the component. We would like to have a single "ConnectSessionContainer" so that we don't see same user creating a seperate session for each component.

Is there a better way of dealing with this other than declaring the "ConnectSessionContainer" in the main application ? Is there a way to check if we have a "ConnectSessionContainer" session already established ? Please help . Thanks.

6 Replies

Avatar

Employee

I am not sure what you are trying to do. But you can add components using the approach below

<?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.events.SessionEvent;
            import com.adobe.rtc.pods.FileShare;
            protected var _fileShare:FileShare;
            protected function login():void
            {
                sess.login();
                sess.addEventListener(SessionEvent.SYNCHRONIZATION_CHANGE, onSync);
            }
           
            protected function onSync(p_evt:SessionEvent):void
            {
                if (sess.isSynchronized) {
                    _fileShare = new FileShare();
                    _fileShare.width = 400;
                    _fileShare.height = 400;
                    sess.addChild(_fileShare);
                }
            }
           
            protected function logOut():void
            {
                sess.removeChild(_fileShare);
                sess.logout();
            }
        ]]>
    </mx:Script>
    <rtc:AdobeHSAuthenticator id="guestAuth" userName="guest"/>
    <mx:VBox id="sessBox">
        <mx:HBox>
             <mx:Button label="login" click="login()" />
             <mx:Button label="logout" click="logOut()" />
        </mx:HBox>
         <rtc:ConnectSessionContainer id="sess" authenticator="{guestAuth}" autoLogin="false" width="100%" height="100%" roomURL="http://connectnow.acrobat.com/uname/roomName">
         </rtc:ConnectSessionContainer>
    </mx:VBox>
</mx:Application>

Avatar

Level 1

Thanks for the response. Let me explain what I am trying to do..


I am trying to create components at different places(screens) of the flex application (not in the same .mxml file).

Each time I create a component, I am using a "AdobeHSAuthenticator" and "ConnectSessionContainer" which is resulting a new participant in the room.


For example

screen1.mxml -

<mx:Panel>

..........................

..........................

..........................

<rtc:AdobeHSAuthenticator id="auth" authenticationSuccess="onAuthSuccess(event);" authenticationFailure="onAuthFailure(event);" />

<rtc:ConnectSessionContainer id="mySession" >
        <rtc:Roster id="myRoster" width="100%" height="100%" />
        <rtc:Chat id="mychat" width="100%" height="100%" />
</rtc:ConnectSessionContainer>
</mx:Panel>

screen2.mxml (in the same application) -

<mx:Panel>

.........................

..........................

..........................

<rtc:AdobeHSAuthenticator id="auth" authenticationSuccess="onAuthSuccess(event);" authenticationFailure="onAuthFailure(event);" />

<rtc:ConnectSessionContainer id="mySession" >
        <rtc:SharedWhiteBoard id="wb" width="100%" height="100%" />
</rtc:ConnectSessionContainer>

</mx:Panel>


Here, I open a screen1 and authenticate as UserA and when I try to open screen2 flex is considering me as another user though I am in the same application.

1) How can I use different components which are in different flex files as a same User ?
2) Should I place my <rtc:AdobeHSAuthenticator> and <rtc:ConnectSessionContainer> in the main application which calls the screen.mxml?

3) What is the best way to do it ?


Thanks for your time !

Avatar

Employee

You should be able to use ConnectSession instead of ConnectSessionContainer (with a single AdobeHSAuthenticator) and pass it to your AFCS components (they all have a "connectSession" property)

Avatar

Former Community Member

For this situation, I agree with Raff - I'd just use a plain ConnectSession, rather than the container (the only difference is that ConnectSessionContainer is a UIComponent, and ConnectSession isn't, so it's a bit lighter). The requirements are as follows :

1. The ConnectSession needs to be instantiated before any of your other AFCS components are instantiated.

... And, that's it! As long as the ConnectSession is first to be instantiated, it becomes ConnectSession.primarySession, and all other AFCS components will look there to find their session object. There's no need to pass ConnectSession references around or anything - I disagree w/ Raff there, unless you need more than one ConnectSession (to a different room for example), in which case you should specify to each component which session they belong to.

How you structure your app is up to you, but instantiate your ConnectSession before your other components, and you'll be good to go.

nigel

Avatar

Level 3

I also use the handy primary session.

First <rtc:ConnectSessionContainer  .. in the main yourapp.xml or yourview.xml then  ConnectSession.primarySession;  for others components.


chatModel.connectSession = ConnectSession.primarySession; 

But thinking about now i should have created a model (puremvc) to handle the ConnectSession.

Avatar

Former Community Member

Hi Coulix,

In general, you shouldn't need to introduce ConnectSession to any of your ISessionSubscribers (unless you're building new, custom ones). If you look in the code for simpleChatModel, it's able to reach out and attach itself to ConnectSession.primarySession by itself. Of course, if you have multiple sessions, you're free to override simpleChatModel.connectSession with the specific session you wanted. The first ConnectSession you instantiate just becomes the primarySession, as a convenience (so devs don't have to hook all their components to a single ConnectSession if they don't want to).

You can also declare multiple ConnectSessionContainers - all components contained within a given container are bound to that ConnectSessionContainer - again, just a nice easy way to make such declarations.

nigel