JoinedRooms property on client is different from server one

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Jochanan
Posts: 79
Joined: 11 May 2018, 09:12

JoinedRooms property on client is different from server one

Postby Jochanan » 29 Oct 2019, 14:57

I have found out, that JoinedRooms property is not being updated from the server.

I have monitored a room on server as well as client. When user joined room, he appeared in the room list and both client and server got their "JoinedRooms" property updated. Problem appeared when user left the room. Admin tool showed correctly, that user is no longer in the room, but client still contained that room in the JoinedRooms list.

I have used AdminTool for server monitoring and Logging/ Live Debugging for the client monitoring.

Both USER_ENTER_EVENT and USER_EXIT_EVENTS are turned on on the room.
C# API: 1.7.12
SFS: 2.13.6

Any thoughts?
Jochanan
Posts: 79
Joined: 11 May 2018, 09:12

Re: JoinedRooms property on client is different from server one

Postby Jochanan » 29 Oct 2019, 15:37

Ok, i have found the issue and it is related to our implementation.

We have this use case:
After players finishes the game, they are deciding whether they would like to rematch or not. Problem is, that the decision whether to rematch or not have to be processed serially (process one player and THEN process another player). We are using ReentrantLock to ensure, that block of code is processed serially.

Additionally part of the code, that needs to be processed is within LeaveRoom handler. Problem was, getApi().leaveRoom() function only schedules the event not fires it imediatelly. This unlucked the lock before the event has been processed and boom, issue.

We have done some changes how to process that part of the code and something had to slip us.
User avatar
Lapo
Site Admin
Posts: 21457
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: JoinedRooms property on client is different from server one

Postby Lapo » 29 Oct 2019, 16:37

Problem was, getApi().leaveRoom() function only schedules the event not fires it imediatelly

No, this doesn't schedule the function. When you call it is executed.
The relative event is fired when the process is complete, which is usually very fast. As regards the event not firing "immediately" I don't what it means.

Any method requires time to execute, which is typically on the scale of several milliseconds. Immediately implies "in no time", which obviously is not possible. But I am not sure what your expectations are... ?

Also it's not clear if you're referring to the server side or client side event. If it's the latter you also have to account for the network latency and the client processing time.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Jochanan
Posts: 79
Joined: 11 May 2018, 09:12

Re: JoinedRooms property on client is different from server one

Postby Jochanan » 13 Nov 2019, 15:11

Lapo wrote:
Problem was, getApi().leaveRoom() function only schedules the event not fires it imediatelly

No, this doesn't schedule the function. When you call it is executed.
The relative event is fired when the process is complete, which is usually very fast. As regards the event not firing "immediately" I don't what it means.


It is scheduled, which means it is not processed immediatelly and it caused us some issues with synchronization. We have solve it. I have written it here just for the info for anyone else who might need it in the future
Jochanan
Posts: 79
Joined: 11 May 2018, 09:12

Re: JoinedRooms property on client is different from server one

Postby Jochanan » 13 Nov 2019, 15:12

The behaviour i was talking about in the previous post relates to the server side
User avatar
Lapo
Site Admin
Posts: 21457
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: JoinedRooms property on client is different from server one

Postby Lapo » 13 Nov 2019, 16:44

Jochanan wrote:It is scheduled, which means it is not processed immediatelly and it caused us some issues with synchronization.

Nope, it is not scheduled.
getApi().leaveRoom() runs in the same thread you are calling it from. The generated events, on the other hand, are not.

I think you're confusing an asynchronous event with scheduling. Scheduling means "delaying" for later processing, which is not the case. There are no delays with this call.

I am sorry if this sounds like nitpicking, but I need to clarify how the call you're referring to works, in order not to confuse other people who might be reading.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 3 guests