isjoinedInRoom problem

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
itsmylifesoham
Posts: 186
Joined: 16 Oct 2011, 14:33

isjoinedInRoom problem

Post 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. :)
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post 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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
itsmylifesoham
Posts: 186
Joined: 16 Oct 2011, 14:33

Post 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;
	}
...
Post Reply