TIPS: The new Room List and Room Groups
Posted: 30 Jul 2010, 05:15
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.
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.