I am currently developing a multiplayer game with a simple room structure where each room can have up to 4 players. Development is going great and we have server-side extensions attached to the Zone to control various different aspects of the game and manage timing, scores, etc for individual rooms. However, I have hit a really confusing issue that I simply cannot resolve after several hours of debugging.
We have a 'play again' button once our game has ended, which will trigger the client to leave their current room, join the lobby and then search for a suitable room to join again (a process that is specified in our extension). Their previous room has a variable set on it stating it is playing/ended, thus meaning it will not match as a suitable room when re-searching for another game. This process all happens when a user first launches the game, and it works every time they first load the game.
So the bug happens in the following use case: I am have a room of 4 players that have just played the game and everything is working correctly - all 4 players can see each other and see their scores are updating. I click play again to do as stated above and join a new room. Then the next 3 players also click play again in sequence and will also appear on player 1's screen to show they have joined. The game starts. The following happens: -
Player 1 can only updates from himself and player 4
Player 2 can see updates from himself, 1 and 4
Player 3 can see updates from everyone
Player 4 can see updates from everyone
The issue here is that the client-side smartfox API cannot see those players and so will not show the updated scores etc for them, even though it saw them join and made them appear (including their variables and usernames). Here is an warning that the console outputs: -
Code: Select all
[WARN] UserVariablesUpdate event, unknown User id: 175
Other notes: We can see the server extension destroys and creates rooms exactly as expected and that all expected players are always sitting in their respective rooms, including on play again. There are no errors in the server log from SmartFox and there does not seem to be any known errors in our client-side code. We are running the latest SmartFoxServer 2X version. The JavaScript output of smartfox.userManager.getUserList() will output only the users the client can see, as stated above.
Could anybody perhaps help shed some light on this issue? Somehow the JavaScript API is not in sync with the server when I relaunch the application. Any suggestions for trying to get to the bottom of this will be greatly appreciated. Please let me know if there's anything else I haven't mentioned that might be able to help figure out what's going on.
** UPDATE **
Logging the sfs.userManager.getUserList() everytime a user enters the new room shows something interesting. The creator of the room (and the next player) seem to get a bit confused and return a user list of their old room, rather than the room they have just joined. Note-worthy for the edit - hoping it could lead somewhere.
Regards,
Owen Ayres