joinRoom event, with asynchronous client to server issues
Posted: 20 Nov 2012, 03:13
When I JOIN a room: On my server I receive the SFSEventType.USER_JOIN_ROOM event and on the client I receive the SFSEvent.ROOM_JOIN, as expected. When the server handles this response, it does a whole bunch of setting up for the gameExtension that is tied to that room. When my client gets the event, it sends a custom extension request (called 'start') back to the server.
Sometimes, the custom client message of "START" gets to the server before the extension is finished setting up all the states (Database calls and such). This is currently happening on my local dev environment, and I know there will be network lag when it is running in production, but I can not count on that as a fix. I can probably fix this pretty easily by having the client delay the sending of the custom START request. Perhaps decoupling it from the ROOM_JOIN event, and waiting for an actual custom READY message from the gameExtension on the server, after it is completely done setting up the extension.
What I was wondering was, is this why the joinRoom API allows us to override the fireClientEvent and fireServerEvent? Perhaps I should tell my joinRoom function to NOT send a client event, but then later artificially send that event when my room is done initialising? Can I even have the server send an artificial roomJoined event? When does the joinRoom server function send the event to the client? As soon as it detects a successful join, or after the handler has completed its code stack? (let me know if this was worded confusingly).
Sometimes, the custom client message of "START" gets to the server before the extension is finished setting up all the states (Database calls and such). This is currently happening on my local dev environment, and I know there will be network lag when it is running in production, but I can not count on that as a fix. I can probably fix this pretty easily by having the client delay the sending of the custom START request. Perhaps decoupling it from the ROOM_JOIN event, and waiting for an actual custom READY message from the gameExtension on the server, after it is completely done setting up the extension.
What I was wondering was, is this why the joinRoom API allows us to override the fireClientEvent and fireServerEvent? Perhaps I should tell my joinRoom function to NOT send a client event, but then later artificially send that event when my room is done initialising? Can I even have the server send an artificial roomJoined event? When does the joinRoom server function send the event to the client? As soon as it detects a successful join, or after the handler has completed its code stack? (let me know if this was worded confusingly).