RoomAdded to clients

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

Moderators: Lapo, Bax

aliko
Posts: 115
Joined: 09 Mar 2013, 16:26

RoomAdded to clients

Postby aliko » 10 Mar 2016, 09:18

Hello,

I disabled subscribe room from client side.
I want to inform all my clients when a new room added. How can i do that?

- how can i send new room object in a SFSObject as an extenion msg?
- or should i dispatchEvent for room added (if i can do that )?

Best Regards
User avatar
Lapo
Site Admin
Posts: 20113
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomAdded to clients

Postby Lapo » 10 Mar 2016, 10:16

[[ This was posted in the wrong section, I moved it under SFS2X ]]

Hi,
your question is not entirely clear.
If you don't allow subscribing to any groups but then you need updates for new Rooms being created it seems you're contradicting yourself.

The whole idea of subscribing to a Group of Rooms is to maintain an updated list of Rooms. If this is what you need then simply allow subscribing to Room Gropus.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
aliko
Posts: 115
Joined: 09 Mar 2013, 16:26

Re: RoomAdded to clients

Postby aliko » 10 Mar 2016, 10:30

Hello Lapo,

Please look my old question ref : viewtopic.php?f=4&t=18305

I want to send users the List of opened rooms or when a new game opened from server extension.
My problem is how can i send Room object or List of rooms as a SFSObject.

Thanks
User avatar
Lapo
Site Admin
Posts: 20113
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomAdded to clients

Postby Lapo » 10 Mar 2016, 10:41

Yes, I remember that discussion.
My suggestion was not recreate the update system, which is a lot of work, but instead use what already exists and filter out the Rooms that you don't want to present to the User.

I still stand by that suggestion, because otherwise you're going to redo a lot of work we've already done for you. Why don't you simply use the information that the server sends and filter it according to your needs?

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
aliko
Posts: 115
Joined: 09 Mar 2013, 16:26

Re: RoomAdded to clients

Postby aliko » 10 Mar 2016, 10:49

Sorry perhaps i missunderstand your answers.

how can a client get games that are waiting oppenent and updates of rooms withhout subscribe?
500 number is only an example, perhaps 10000 or more started games will be in a group.
User avatar
Lapo
Site Admin
Posts: 20113
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomAdded to clients

Postby Lapo » 10 Mar 2016, 11:05

My suggestion is to use the Room Group subscription to one or more Groups.

500 number is only an example, perhaps 10000 or more started games will be in a group.

Well, for starters how many players will be in a Room? 2? 4?

If you plan 10K Rooms you will need to handle 40K CCU. Are you sure it is realistic? I am asking because these numbers are very high. 40K CCU is roughly equivalent to 3-4 million DAU... not many games get this high.

It's great to think big but first one has to concentrate on making the game work for a realistic scale. Room Groups allow you to divide Rooms in different "containers" so that users can only see a part of the list, instead of a huge one.

If your game will grow in the 10s of thousands of CCU you will anyways be able to organize your game Rooms into multiple Groups and maintain a reasonable size for those rooms lists.

my 2c
Lapo

--

gotoAndPlay()

...addicted to flash games
aliko
Posts: 115
Joined: 09 Mar 2013, 16:26

Re: RoomAdded to clients

Postby aliko » 10 Mar 2016, 11:20

2 players will be in a room. This is a backgammon game.
Currently i have app. 1000 CCU.

Perhaps your are right, I'm worring unnecessarily.
Anyway kindly, can you inform me regarding how can i send the rooms to my users?
I mean can you go on your example code :) (Send the Room list to the client section...)

Code: Select all

// Filter all Rooms that have a RoomVariable 'waiting' set to true
MatchExpression exp = new MatchExpression('waiting', BoolMatch.EQUALS, true);

// Obtain the list of Rooms from a specific group
List<Room> rooms = getParentZone().getRoomListFromGroup("MyRoomGroup");

// Find up to 5 rooms matching the provided expression
List<Room> filteredRoomList = getApi().findRooms(rooms, exp, 5);
                   
// ... Send the Room list to the client ...
User avatar
Lapo
Site Admin
Posts: 20113
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: RoomAdded to clients

Postby Lapo » 10 Mar 2016, 11:25

A Room object cannot be serialized and sent over the wire as it is. It is too complex and it will result in too much data.

However you can extract from each Room object only the data you need to send to the client (e.g. name, id etc...) and send them back in a custom data structure, made with SFSArray or SFSObject.

Makes sense?
Lapo

--

gotoAndPlay()

...addicted to flash games
aliko
Posts: 115
Joined: 09 Mar 2013, 16:26

Re: RoomAdded to clients

Postby aliko » 10 Mar 2016, 11:29

Ty very much. I thoght like that too and did it.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 7 guests