Page 1 of 1

How to check room joinable in room list?

Posted: 08 Sep 2015, 18:03
by hoanghuybao
Hi admin,

We can get room list using:

Code: Select all

and then foreach the room list to get the room name. User will try to sending request join the room

Code: Select all

sfsClient.send(new JoinRoomRequest(roomName));
, server returns an event ROOM_JOIN or ROOM_JOIN_ERROR. In case the room is full, we get an error message "Room demoRoom is full".
My question: Why do we support a method which can check room is full for example:room.isFull() before we send request to join the room?


Re: How to check room joinable in room list?

Posted: 09 Sep 2015, 07:56
by Lapo
It is not reliable on the client side, because there is always the possibility that something changes during the time between the client sends his request and when it actually gets to the server.

Imagine a situation in which both User A and User B want to join Room 1, they both see that there is one player slot free, they both send the request at the same time. Only the server can resolve this situation, and it solves it by joining the User whose request got the server first.

That's why the error is thrown by the server and the client is not reliable in this sorts of things.

Hope it helps.

Re: How to check room joinable in room list?

Posted: 12 Sep 2015, 13:36
by hoanghuybao
Thanks for your comment. It is good solution in this case.