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

on_reconnect callback #972

Merged
merged 3 commits into from
Mar 12, 2024
Merged

on_reconnect callback #972

merged 3 commits into from
Mar 12, 2024

Conversation

bubbleboy14
Copy link
Collaborator

@bubbleboy14 bubbleboy14 commented Mar 1, 2024

Ticket 971 (#971) discusses an ambiguity in our callback system between the connection opening for the first time and subsequent automatic reconnects.

To address this, this PR adds support for an on_reconnect callback. The on_reconnect callback (instead of the on_open callback) is called from setSock() on a reconnect. If no on_reconnect callback is provided, the previous behavior (of calling on_open on a reconnect) is preserved.

Ticket 974 (#974) involves the somewhat related case of WebSocketApp reuse after the server intentionally disconnects. @GooVincent identified the solution, setting has_done_teardown to False.

@engn33r
Copy link
Collaborator

engn33r commented Mar 12, 2024

This looks reasonable to me. Adding the new on_reconnect callback gives the user more flexibility without any compatibility issues. Setting has_done_teardown to false in run_forever makes sense to fix this case, it's a nice catch.

@engn33r engn33r merged commit 2dfecf7 into master Mar 12, 2024
14 of 18 checks passed
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.

None yet

2 participants