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

Implemented onheartbeattimeout callback for ping/pong. #151

Merged
merged 2 commits into from
Mar 20, 2023

Conversation

robinmaree
Copy link
Contributor

It seems the socket.onDisconnect callback function is called late. But we do see the Server unreachable from heartbeat error message very quickly (setHeartbeatTimeoutMs = 3000ms) after disabling WiFi. I’ve debugged this a bit, it’s calling WebSocketAdapterText:close, but takes some time before calling the WebSocketAdapterText.onClose callback (which calls the socket.onDisconnect)

My idea is that the WebSocket.close function is taking a while before completing since it’s doing a closing handshake on the socket (see: WebSocket.close() - Web APIs | MDN).

This PR implements an additional callback onheartbeattimeout which will be called directly when the ping/pong failed. This way we can detect connection problems sooner and inform the players. We have conducted internal testing on this build and verified that it is functioning properly.

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2023

CLA assistant check
All committers have signed the CLA.

@robinmaree
Copy link
Contributor Author

@lugehorsam As per our discussion on the forum, please review this pull request and provide your feedback. Additionally, please let me know if you have any suggestions on achieving the same outcome without using an extra callback, to avoid any confusion for the developers.

Copy link
Contributor

@lugehorsam lugehorsam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @robinmaree

@lugehorsam lugehorsam merged commit 7d557b6 into heroiclabs:master Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants