Page 1 of 1

isjoinedInRoom problem

Posted: 04 Feb 2012, 05:12
by itsmylifesoham
Hi,

i have a practicelobby static room(group id:practice) and a premiumlobby static room(groupid : premium) both in one zone.

when the user clicks on the premium lobby button i need to switch him from practicelobby to premium lobby room.

in the function which is switching i first make a check like

Code: Select all

public function toggleLobbyRoomTo(newroomName:String):void
{			
if( sfs.mySelf.isJoinedInRoom(sfs.getRoomByName(newroomName)))
				return;
i return becoz i dont want to call a joinroom request if the room is already joined. Now the problem :

the line at SFSUser.isjoinedInRoom() function throws an exception "cannot access method or property of null object reference".

i figured out that if i set the group id on both these rooms to be "default". then this exception doesnt occur!

then i set it to "lobby" on both as their groupid. and it occurs again!

from what i figure out isjoinedinroom() function only works when the room you are passing to it is their in your local roomlist.

is this the case and expected behaviour?

should i be handling this exception as an indication that the room is not present in the local room list and hence ofcourse the user is not joined in it. but is this the right way?

or should i first make a check that the room exists in localroomlist and after that only check if the user is joined into that room using isjoinedinroom function?

any ideas?
thanks. :)

Posted: 04 Feb 2012, 21:01
by rjgtav
Hi.

What's happening is that you're only subscribed to the default Room Group, so you don't receive the room list of the other room groups, that's way it gives that error.

So, you have to subscribe to those room groups if you want to get their room lists.

Posted: 05 Feb 2012, 04:53
by itsmylifesoham
thanks.

before performing sfs.myself.isjoinedinroom() check i am doing a check to see if local room list contains that room like so :

Code: Select all

public function toggleLobbyRoomTo(roomName:String):void
{			     
if(sfs.roomManager.containsRoom(sfs.getRoomByName(roomName)))
	{
					 if(sfs.mySelf.isJoinedInRoom(sfs.getRoomByName(roomName)))
						return;
	}
...