Skip to content

Fixes leak and Socket.disconnect() not calling onClose#112

Merged
dsrees merged 3 commits intodavidstump:masterfrom
darrenclark:fix-socket-disconnect-not-calling-onClose
Aug 30, 2018
Merged

Fixes leak and Socket.disconnect() not calling onClose#112
dsrees merged 3 commits intodavidstump:masterfrom
darrenclark:fix-socket-disconnect-not-calling-onClose

Conversation

@darrenclark
Copy link
Contributor

Fixes #110, specifically:

I'm not 100% sure calling onConnectionClosed() is the right option here though, as there may be unintended side effects (like the autoreconnect timer starting) @davidstump thoughts?

Since connection.delegate is nil'd out, the Socket wasn't getting the
`websocketDidDisconnect(socket:error:)` delegate message so it'd never
call onClose callbacks.

This also fixes an issue where the Socket would never be deinit'd
because the current run loop had a strong reference to it (via the
heartbeatTimer)
instead of relying on the `onConnectionClosed()` function.
`onConnectionClosed()` does some additional things that we don't want
(i.e. starting the reconnect timer) to happen when a Socket is
explicitly disconnected.
@darrenclark
Copy link
Contributor Author

@dsrees Thanks for taking the time to review this!

I've made the changes & added a test for this.

Copy link
Collaborator

@dsrees dsrees left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for the fix

@dsrees dsrees merged commit ade5c27 into davidstump:master Aug 30, 2018
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.

2 participants