Page 1 of 1

TIPS: The new Room List and Room Groups

Posted: 30 Jul 2010, 05:15
by Lapo
Every one who is familiar with SFS 1.x knows that the client is quite strict on the subject of Room List.
The client must always call the getRoomList() method before getting started etc...
As expected by many we have dealt with this rigidity from the grounds up with SFS2X and the problem no longer exists.
The Room List will always be available at any moment on the client side, there's no manual request to send and the updates are all transparent.

Room Groups
One of the most important settings in the SFS2X Zone is the defaultGroups value. Here you specify which Room Groups the User will be subscribed to when he is logged in the Zone.

By default SFS2X defines one single group called "default" and, unless you configure it differently, this is the only group that any User is auto-subscribed to upon login.

This makes SFS2X behave exactly like his predecessor. The fun stuff begins when you add more Groups to the mix and let the User listen to their events by configuring the defaultGroups value.

Let me give your a few examples:
defaultGroup = ""
This is equivalent to listening to the "default" Group, no particular surprises. The User acquires the Room list of this group at login time and will receive updates just for this Group

defaultGroup = "default,chess"
The User will receive a RoomList containing the Rooms from the two specified Groups and will keep receiving update events from those two.

etc... you should get the idea

Dynamic Group subscription:
Here comes the fun part. Not only you can choose what the User should "see" as soon as he joins the Zone but you can dynamically choose which Groups to listen or avoid at any time at runtime.

There are two new requests called SubscribeGroup and UnsubscribeGroup which will allow the developer to add or remove all Rooms from a Group (and relative events) to the client Room List.

Of course the client and server API allow you to easily search for Rooms from a specific Group etc... Additionally the SmartFoxBits 2X UI components already provide support for this feature.

Want to play a game of Black Jack?
Subscribe to the "BlackJack" Group and voilà, the client obtains an updated Room List with all the Rooms/Games from that place.
Everything is kept in sych behind the scenes and when you're done with playing Black Jack games you can drop the Group and stop listening to its events.

More advanced Room stuff:
You can join any Room by knowing its name or Id even if its not in your current Room List.
For example this allows Users to invite each others in their respective places without any pain. If these Rooms are out of the current client scope the system will figure it out and transparently update the client.

This approach can be useful when you want the User to join a specific Room without having to subscribe to the Room Group and receive all its events.

Posted: 13 Apr 2011, 23:23
by xLite
Is there anyway to scrap the room list? It's so innefficient sending the client information of other rooms which it may never need. I'd rather the server handle everything and send the rooms that the client wants to deal with. So when the user logs in, the server joins it to the appropriate room and sends the room data to the user and all events in that room. Then when the users wants to switch room the server joins the user to the new room, leaving the old one and sends the data for that room etc.

I've never liked sending all the rooms at once, groups doesn't help either. Is there a way to just ignore this room list idea altogether?

Posted: 13 Apr 2011, 23:49
by Democre
I think if you assign rooms to groups other than default, and just leave your users subscribed to the default group, then the users will not get the list of rooms from other groups. They would get an empty list of rooms for the default group if there are no rooms in that group.

Posted: 16 Apr 2011, 15:37
by xLite
Is that the best method or is there a way of disabling the client side room list altogether via a built in command perhaps?

Posted: 17 Apr 2011, 18:30
by Democre
I believe this is the closest you will get to "disabling" the room list. You will in effect get no room list if your user is not subscribed to the groups which contain rooms.

I may be wrong, but I have not seen any such API to disable room lists. It is a subscription model, so your clients would merely not subscribe to the room groups. You can use the API method UnsubscribeGroup (as mentioned in the original post) to explicitly unsubscribe from room groups. I have not played around with unsubscribing from all groups. Instead, I have done what I mentioned above, and left the client subscribed to default group and creating all rooms in other groups. My client never gets any of those rooms. I don't have an event handler for room list changes, so I don't know if the client is still getting any room list updates (even if they are empty).

Create Group at run time and Assign room to each group.

Posted: 31 May 2011, 11:27
by peter890
Iam new to the SFS2x, want to learn on Room/group which is new in SFS2x.
can any one guide how to create group at run time and assign rooms to it.

Democre wrote:I believe this is the closest you will get to "disabling" the room list. You will in effect get no room list if your user is not subscribed to the groups which contain rooms.

I may be wrong, but I have not seen any such API to disable room lists. It is a subscription model, so your clients would merely not subscribe to the room groups. You can use the API method UnsubscribeGroup (as mentioned in the original post) to explicitly unsubscribe from room groups. I have not played around with unsubscribing from all groups. Instead, I have done what I mentioned above, and left the client subscribed to default group and creating all rooms in other groups. My client never gets any of those rooms. I don't have an event handler for room list changes, so I don't know if the client is still getting any room list updates (even if they are empty).

Posted: 31 May 2011, 12:28
by Lapo

Posted: 01 Jun 2011, 04:47
by peter890
Lapo wrote:http://docs2x.smartfoxserver.com/DevelopmentBasics/join-and-create-rooms
http://docs2x.smartfoxserver.com/Develo ... chitecture



Thank you.

Creating room and assign to a group , i need to do at server side using Java.

Also send public message to all user's who are in that group.

Posted: 01 Jun 2011, 08:54
by Bax
Please read the server-side API Javadoc: you will find all the methods to do what you need. Start from the ISFSApi interface.

Posted: 02 Jun 2011, 11:58
by peter890
bax wrote:Please read the server-side API Javadoc: you will find all the methods to do what you need. Start from the ISFSApi interface.



ok thankq

Switch between rooms

Posted: 08 Jun 2011, 08:51
by peter890
peter890 wrote:
bax wrote:Please read the server-side API Javadoc: you will find all the methods to do what you need. Start from the ISFSApi interface.



ok thankq


how do i switch between zones using groupId

Posted: 08 Jun 2011, 12:19
by Bax
You can't switch zones. The Zone is selected during the login process. In order to switch zone you have to logout and login again.

Re: TIPS: The new Room List and Room Groups

Posted: 02 Mar 2014, 05:00
by Carl Lydon
There is a typo above:

defaultGrouo = "default,chess"
Should be
defaultGroup = "default,chess"

Re: TIPS: The new Room List and Room Groups

Posted: 02 Mar 2014, 12:48
by Lapo
Thanks