Client doesn't get onJoinRoomError with non-existent room

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

Post Reply
kopke
Posts: 4
Joined: 29 Jul 2009, 15:48

Client doesn't get onJoinRoomError with non-existent room

Post by kopke »

Hi,

We're running SFSPro 1.6.6, and have a situation where the client application is attempting to join a room that does not exist in the current zone. The server logs indicate that the client requested to join an invalid room (it does not mention which room) but the client never receives any indication that the join room request has failed.

My understanding is that an onJoinRoomError event should be fired on the client in this situation. Is that assumption incorrect?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

Hi,
from client side it is quite strange that you attempt to join a non-existent room because you normally get the id of the room to join from the Room List.

The server doesn't respond to a client asking for a non-existent room because normally hackers attempt to do things like these, like flooding the server with bad join requests. If the server would respond it would simply waste resources...

Normally you always query the room list before joining a Room.
Lapo
--
gotoAndPlay()
...addicted to flash games
kopke
Posts: 4
Joined: 29 Jul 2009, 15:48

Dynamic room systems

Post by kopke »

Lapo wrote:from client side it is quite strange that you attempt to join a non-existent room because you normally get the id of the room to join from the Room List.
That applies only to the case of non-dynamic room systems. With dynamically managed rooms, even a room list does not guarantee that a given room will still exist when the server receives a join request.
Lapo wrote:The server doesn't respond to a client asking for a non-existent room because normally hackers attempt to do things like these, like flooding the server with bad join requests.
There are ways to deal with request flooding that don't involve withholding information from the client.

I take it there's no way a client will know if it tried to join a room that doesn't exist in a dynamically managed room system, beyond writing a custom extension?
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

I've verified and the error is fired correctly when you request to join a Room that doesn't exist, using the onJoinError event.
The Client API, however, perform a check on the local room list before firing the join-room request. If the room is not found in the local room list a trace is sent to the the Flash IDE. This is because it's only a warning for developers and this error should be noticed while testing.

In fact if you wish to join a room that was just created you will need to wait for the onRoomAdded event which confirms the successful creation.
I take it there's no way a client will know if it tried to join a room that doesn't exist in a dynamically managed room system, beyond writing a custom extension?
Nope, there's no need to write an extension.
Lapo
--
gotoAndPlay()
...addicted to flash games
kopke
Posts: 4
Joined: 29 Jul 2009, 15:48

Post by kopke »

Lapo wrote:I've verified and the error is fired correctly when you request to join a Room that doesn't exist, using the onJoinError event.
We have sample code that uses the Smartfox AS3 interface to try joining a room that does not exist in the current zone and we never have been able to receive the onJoinRoomError event in our client.
You mention "onJoinError", is this an undocumented event? I was unable to find it in the Smartfox API SFSEvent documentation.
Lapo wrote:The Client API, however, perform a check on the local room list before firing the join-room request.
That's fine, but without the Smartfox server firing error events we can potentially enter a race condition. If the server creates a room, the client is updated about the new room's existence and tries to join it, and while the join request is in transit the room is removed from the server. Then the client has to also listen for room deletions that concern a room it might be joining. This appears to be more easily solved by having catching an onJoinRoom event in the case of joining a non-existent room.
Lapo wrote:In fact if you wish to join a room that was just created you will need to wait for the onRoomAdded event which confirms the successful creation.
Why should the client need to wait for that event? I understand that the client probably should wait for the event, but I don't see why its' a requirement.

Thanks for your help, by the way, Lapo.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

We have sample code that uses the Smartfox AS3 interface to try joining a room that does not exist in the current zone and we never have been able to receive the onJoinRoomError event in our client.
From client side this is not possible because the API will perform a check in local room list before attempting the join.

Also if the Room doesn't exist I am wondering where does the client gets the id or name from? The RoomList should be the only source from which the client can decide where to go.

The onJoinRoomError is documented here:
http://www.smartfoxserver.com/docs/docP ... nRoomError
If the server creates a room, the client is updated about the new room's existence and tries to join it, and while the join request is in transit the room is removed from the server. Then the client has to also listen for room deletions that concern a room it might be joining.
This is a very particular case.
If this happens the user will remain in the current Room and a server side error will be logged, however no failures are notified to the client.
However the client will be notified that the room was removed via the onRoomDeleted event.

Joining from server side can eliminate the problem because there's no delay between the Room creation and the subsequent join.
Why should the client need to wait for that event? I understand that the client probably should wait for the event, but I don't see why its' a requirement.
Because before that event the client has no idea that such room exists.
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply