Expand my Community achievements bar.

Managing Users

Avatar

Level 2

Hi There,

Can anyone shed some light on how I would distinguish between users? This test always passes as true in the first case.. Will service.session.userManager.myUserID always be my ID or is it the ID of the user running the app?












               var button:TicTacToeButton = e.currentTarget as TicTacToeButton;

               var player1:UserDescriptor = service.session.userManager.userCollection[0];

               var player2:UserDescriptor = service.session.userManager.userCollection[1];



               if(player1.userID == service.session.userManager.myUserID) {

                    trace("im the first guy");

                    trace("myUserID: " + service.session.userManager.myUserID);

                    trace("player1UserID: " + player1.userID);

                    button.currentState = 'x';

               }


               else if(player2.userID == service.session.userManager.myUserID){

                    trace("im the second guy");

                    trace("myUserID: " + service.session.userManager.myUserID);

                    trace("player2UserID: " + player1.userID);

                    button.currentState = 'o';

               }

3 Replies

Avatar

Former Community Member

Hi,

I am not sure if I understood your question correctly, but userID is the ID of an user who is connected to the room, and your userID is also one of them which is made specific with myUserID.

For e.g.

If there are three players in the room player1,player2 and player3 and you are one of them. Then the userManager.userCollection will have all these 3 player's userDescriptor that will in turn contain their respective userIDs.

And if your iterate over the userCollection, one of the userIDs will match your ID i.e. myUserID and that userDescriptor is your userDescriptor. I hope it makes things clearer.

Thanks

Hironmay Basu

Avatar

Level 2

Thanks that does begin to clarify that things are as expected. That said, when I have multiple instances of my app open and trace out userID's from the userCollection, I get this. Then, when I try to distinguish between ID's it treats them as if they are the same string.

Is it that all users are getting an ID instance of my ID and therefore it treats them as matches? I would think that the /2 or /3 would make them unique. Is that not the case?

Thanks so much for the help!

               trace("myUserID: " + service.session.userManager.myUserID);



               for(var i:uint=0; i<service.session.userManager.userCollection.length; i++){


                    var user:UserDescriptor = service.session.userManager.userCollection[i];


                    trace(i + ": " + user.userID);


               }



myUserID: WCD-05B443293D57519099200195/3

0: WCD-05B443293D57519099200195/3

1: WCD-05B443293D57519099200195/2

2: WCD-05B443293D57519099200195

Avatar

Former Community Member

Hi,

Isn't the myUserID value different for different instances? They also should be A, A/2, A/3 for different instances and if you loop over, you get to see all them as different userIDs.

Thanks

Hironmay Basu