Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS/Mobile Safari: onLeave not triggering in the client-side #100

Open
endel opened this issue Nov 16, 2021 · 5 comments
Open

iOS/Mobile Safari: onLeave not triggering in the client-side #100

endel opened this issue Nov 16, 2021 · 5 comments
Assignees

Comments

@endel
Copy link
Member

endel commented Nov 16, 2021

Reported by Josh via Discord (https://discord.com/channels/525739117951320081/526083188108296202/910023542702223380)

Hey there!
Does anybody know why onLeave might not be called on the client? Testing on iPhone and turning off wifi + cellular doesn't call the method.
Only way I've found to call the onLeave method on the client is to kill the server while still connected to it.
Any ideas?

@endel
Copy link
Member Author

endel commented Nov 17, 2021

Josh just shared his reproduction case here https://github.com/jorasso/colyseus-examples

Okay, @endel I was able to get a sample project showing the onLeave issue.
The steps to reproduce are in the README and there's a video there too.
But you'll see the onLeave isn't being called when disconnecting from the internet, only when being removed from the room.
The repo is here: https://github.com/jorasso/colyseus-examples
Thanks so much and let me know if you have any questions!

@lpsandaruwan lpsandaruwan self-assigned this Nov 19, 2021
@lpsandaruwan
Copy link
Contributor

This functionality seems to be working fine in Chrome/Windows. I will investigate in Safari/Mac.

@lpsandaruwan
Copy link
Contributor

lpsandaruwan commented Nov 23, 2021

Hi @endel,

onLeave seems working fine in Mac/Safari and IOS/Safari. I've tested on both platforms. Please check this video.

@endel
Copy link
Member Author

endel commented Nov 23, 2021

Hi @lpsandaruwan, I see your video and I think by clicking on "disconnect" does not have the same effect as fully disconnecting from the wi-fi network as described by Josh

Testing on iPhone and turning off wifi + cellular doesn't call the method.

@joshfeinsilber
Copy link

Hey y'all!

I have a little more information on this. It looks like the disconnection detection is only occurring on the server.

Visit here and scroll down just a bit as it lists steps to detect disconnects on the client.

image

However, looking at the Websocket Transport, there currently isn't anything checking for the ping messages sent from the server. I also didn't find anything in onMessageCallback.

In our project, we're going to start looking into implementing this. If it works out, we'll make a pull request. However, I suspect this will involve adding a new option on the client for the duration of the interval (should be just a little higher than pingInterval on the server).

We also might try to go a bit further by instantly detecting an offline event and calling the close event immediately.

But based on me looking around a bit, I believe that's why this issue is occurring. There's nothing on the client currently that detects disconnections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants