Can I dynamically assign rooms to groups in extesion?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Alex
Posts: 131
Joined: 03 Sep 2006, 09:15

Can I dynamically assign rooms to groups in extesion?

Postby Alex » 30 Jul 2010, 10:58

Hi

The new SFS looks very impressive I've been playing with some of the features and I'm interested if the following can be done with the new Room groups feature.

Let's say I have a Lobby room that holds all the users that are not playing. In the Lobby room I'm showing list with all the game rooms that have been created.

Now my question is - Can I show only the game room which are not full(userCount < maxUsers)? . For example can I have 2 Game room groups "FullGames" and "NonFullGames". All the users in the Lobby are listening for events only in the "NonFullGames" group. Then in a custom extension I'm listening for userLost/userJoin event and dynamically add/remove the room to the correct group.

Is this possible?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Jul 2010, 12:20

Hi, no this is not possible for the simple reason that a group is just and attribute that identifies the Room, not a dynamic expression resolved at runtime.

However... there's another simple way to do this with no server code.
Simply loop through the list of Game Rooms and separate all the full games from all the o non full ones.
For example you could show them in two separate lists.
As regards the Room events there is no problem because you will be notified for every event in that group, so at the end of the day this is more of a visual/GUI problem than anything else.

You should also check the GameAPI document. You will notice that the API already provide a way to notify which games are started and which not via Room Variables.
This property could as well be used to show two separate lists, one with the games already started and one with those waiting for players...

Lots of options here ... :D
Lapo
--
gotoAndPlay()
...addicted to flash games
Alex
Posts: 131
Joined: 03 Sep 2006, 09:15

Postby Alex » 30 Jul 2010, 13:17

Hi

I'm currently using the solution you suggest "Simply loop through the list of Game Rooms and separate all the full games from all the o non full ones. "

Now the problem is the traffic - currently each user receives all room's data when he joins the lobby - which is when he first loads the game and then every time after the game is finished 0 he is returned to lobby. Usually there are about - 5 to 10 NonFull rooms and about 200 or more Full rooms - so if I'm able to receive only NonFull rooms I'll save a lot of traffic.

Now I saw that I can use MatchExpression to get the NonFull rooms (or the games that are not started) at the server side. Can I use MatchExpression at the client side?

Instead of this:
// Retrive the rooms list
var roomList:Array = sfs.roomManager.getRoomList();

Can I specify MatchExpression at the client or I should create my extension that will call the MatchExpression. I saw that there is QuickJoinGameRequest - which is almost what I need - but I need to receive back the list of joinable games.

Also will you release the client API source code?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Jul 2010, 17:56

Now the problem is the traffic - currently each user receives all room's data when he joins the lobby - which is when he first loads the game and then every time after the game is finished 0 he is returned to lobby. Usually there are about - 5 to 10 NonFull rooms and about 200 or more Full rooms - so if I'm able to receive only NonFull rooms I'll save a lot of traffic.

This is not clear.
Didn't you say wanted to show the both the Full Rooms and the Non Full Rooms? If so what's the difference?
Additionally you shouldn't worry about the traffic now, the new binary protocol is immensely more efficient and you can fine tune the UserCountUpdates to reduce the traffic of count updates.

Can I specify MatchExpression at the client or I should create my extension that will call the MatchExpression.

No you can't do that.
When you join a Group your local Room List is auto updated with all the Rooms in that Group.

I saw that there is QuickJoinGameRequest - which is almost what I need - but I need to receive back the list of joinable games.

This is not the way this is intended.
It's called QuickJoin because it will find the first Room available in the system with your criteria and join you there. It's not a Room search function.

If you want to search for specific rooms you should use the FindRoomRequest which will return a list of Rooms matching your request

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
Alex
Posts: 131
Joined: 03 Sep 2006, 09:15

Postby Alex » 30 Jul 2010, 18:38

Hi

10x for the reply - I'll experiment little bit more with the new API
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 30 Jul 2010, 18:43

Btw, a few more comments.

Dynamically moving one Room from a Group to another is not an intended feature. In general it would complicate things significantly, while our focus is to keep things as simple as possible while extending the framework features.

In particular this would require to generate new events to notifiy when a Room is removed from a Group or added to another one.
Not only but Rooms moving around like that would cause other complicated scenarios... such as a User joining a Room that is being moved to another Group while that User is not subscribed to the Group.

Finally as regards your comment on bandwidth I would expect a much better performance if you join one Group that contains both Full and Non-Full rooms.
When you do this you obtain the room list once and then just tiny updates when necessary.

On the contrary using two different Groups that the User can continuously subscribe and unsubscribe would generate more traffic to the server and tons more to the client that each time would receive the entire room list of the Group.
Lapo

--

gotoAndPlay()

...addicted to flash games
Alex
Posts: 131
Joined: 03 Sep 2006, 09:15

Postby Alex » 31 Jul 2010, 09:20

Hi

Here few more thoughts on the subject about your last comment .

Finally as regards your comment on bandwidth I would expect a much better performance if you join one Group that contains both Full and Non-Full rooms.
When you do this you obtain the room list once and then just tiny updates when necessary.


Currently I'm implementing things like that:

1. User joins the lobby
2. User receive all game rooms
3. User joins the game room, leave the lobby - and stops listening for any external room events (room add,room delete etc.)
4. User leave the game and joins the lobby
5. User request again all game rooms

Now the other option I was considering is the following

1. User joins the lobby
2. User receive all game rooms
3. User joins the game room - but doesn't leave the lobby and continues to listen for the external room events( room add, room remove ) - this way the game room list stays in sync and when I go back to lobby I'll have the correct game room list.
4. User leave the game and joins the lobby

Now the problem with my current implementation is that I have seldom but heavy requests, while in the second variant I'll have a lot of small and fast requests. The problem with the second variant is also that if I have 1000 users online - all of them should receive the room updates - which I think is a lot of traffic at the server.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 31 Jul 2010, 13:11

There are several things that are not clear:
1. User joins the lobby

Which Group is the lobby in?
2. User receive all game rooms

Is the lobby Room together with the games Room? Same Group?
Also, can't you split the games in multiple Groups?

3. User joins the game room, leave the lobby - and stops listening for any external room events (room add,room delete etc.)

This is not clear.
Leaving the Lobby does not automatically stop the client from listening to the Room events in the current group. You should unsubscribe from all Groups to obtain this.
4. User leave the game and joins the lobby
5. User request again all game rooms

Again it's not clear how this is done.

1. User joins the lobby
2. User receive all game rooms
3. User joins the game room - but doesn't leave the lobby and continues to listen for the external room events( room add, room remove ) - this way the game room list stays in sync and when I go back to lobby I'll have the correct game room list.
4. User leave the game and joins the lobby

To me this makes much more sense although again there's no apparent use of Groups here which would probably help.

Even if you have only one game type you could find ways of splitting games over multiple Groups. You could have a Rookie group for beginners and a PRO group for more expert players.
This is just a suggestion but you get the idea...

Also you seem so worried about Room updates but I don't see why, those updates are very small and efficient.

My 2c... I would concentrate on the game itself and not on these things. The server does the best possible job for you behind the scenes to keep users in synch so that you don't have to worry about it.
Let it manage that for you. :)
Lapo

--

gotoAndPlay()

...addicted to flash games
Alex
Posts: 131
Joined: 03 Sep 2006, 09:15

Postby Alex » 31 Jul 2010, 15:04

Hi

I forgot to specify that I was talking about SFS 1.6. I've done the first implementation with 1.6.5 - and its pretty stable so for( the lobby is normal room - so it receives room update, the game rooms doesn't )

Now I'm exploring the options in the new SFS 2X and I'm searching if there is a better way in which I can do the things.

Now here is solution I'm thinking about and the reason why I want to receive only non full rooms. (not sure if it can be done easy in SFS 2x but I think I can do it)

1 User joins the lobby

2 User receive only Non full rooms - the user is not interested in the full rooms. There could be an event that will notify that a room is no longer full, with param the room. This event will be fired only to the users in lobby- only they are interested in this event.

3 User joins the game and stop listens for external room updates - Usually when user joins the game he stays there until he decides to stop playing and leave the game - disconnects - so there is no need the user to constantly listens for external room events.

4 User goes back to lobby - then the user receives again only the non full rooms - the user is not interested in the full rooms.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 66 guests