[AS3] Simple Multiplayer: some trouble with rooms

Hi.
I wrote my code similar to what is in the Help for SMP
At the beginning program makes length check array rooms[].

rooms.length > 0.

If the room does not exist then it is created and the player is put into it.
.idnet.multiplayer.roomCreate('game', null, null, 'nowjoin', createOptions)

For the second player program already works with rooms that exist first and foremost looking for a room with a player who has already created room.
Here, I used in condition variable playerCount
if (rooms[i].playerCount == 1)
but now playerCount returns 0 when the player is in the room.

I set a breakpoint and saw that playerCount == 0 while object players contains one player.

Maybe that something has changed in API, since I did not make changes in code. How can I rectify the situation, or maybe there are other solutions?

Hi Tokar, Thanks for reminding me. This issue of playerCount not being accurate has been poping up. I did some work on the code and it should be resolved now. Please test again and let me know if any problems show up.

Now my code works well. :heavy_check_mark:
Thanks Eddie!

1 Like

Test which I did yesterday.
I created a 2 rooms and noticed that they still exist today and in one of them 2 players still there. Previously, I saw that the rooms were removed after some time.

Room Created: 1463508575 - GMT: Tue, 17 May 2016 18:09:35 GMT
Last Active: 1463508593 - GMT: Tue, 17 May 2016 18:09:53 GMT

And I have a question:
I noticed that after the player was joined in the room and closed the SWF file, player is still some time in the room. I assume that this is due to the fact that his session was not completed.

Can I somehow influence it, such as to inform the server that a particular session can be complete. Or catch such an event as a (closing SWF) and do for player roomLeave(); ?

Ah, the fix from yesterday revealed another problem that was preventing rooms from getting removed. I submitted a patch and it should be fixed

Like rooms, stale sockets for users will also get deleted. Normally, both rooms and users are deleted after 15 minutes of inactivity.

Your are right that a socket can sometimes close without sending any data indicating it is about to close. In this case, it will appear to be waiting but will be unable to receive data. It seems rare for this to happen but if it becomes a problem, we can look into detecting it. I think the users still showing in rooms was related to the room bug and not unclean disconnects.

I understand, then it is not a problem.

I did a test again, I put the players in the room, closed the SWF-files in a few minutes the players were removed from the room, and later room was removed too.
It seems all is well, many thanks!

Sure, any time. Thanks for reporting the problem. Usually I see errors show up in our reporting software. Hopefully, we can get that fixed soon, so these problem can be fixed quicker. :smile:

2 Likes
Y8 Games