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

Add a destroy method #92

Closed
scyclops opened this issue Sep 9, 2019 · 6 comments · Fixed by #93
Closed

Add a destroy method #92

scyclops opened this issue Sep 9, 2019 · 6 comments · Fixed by #93

Comments

@scyclops
Copy link

scyclops commented Sep 9, 2019

It would be useful if the client API provided a way to cleanup and destroy a Centrifuge object.

@FZambia
Copy link
Member

FZambia commented Sep 10, 2019

Hello, any insight on how you are planning to use this method? And what it should actually do beyond disconnect and cleaning up internal state?

@scyclops
Copy link
Author

I think disconnecting and cleaning up internal state is all it should do.

For my use case, only authenticated users need to maintain an active connection to Centrifugo. So when a user logs out, I need a way to destroy the connection.

@FZambia
Copy link
Member

FZambia commented Sep 10, 2019

Maybe disconnect method already does what you need?

@scyclops
Copy link
Author

I tried using disconnect but it doesn't work when the client is already in a disconnected state because of the disconnected check on this line:

if (this._isDisconnected()) {

For example:

  1. User connects to centrifugo
  2. User internet stops working (so client is disconnected and is trying to reconnect)
  3. User logs out of app (disconnect is called but does nothing because client is already in disconnected state because of 2)
  4. User internet starts working again while they are stilled logged out (so client reconnects to centrifugo even though disconnect was called in 3)

I also have a second use case where SockJS is only loaded if the first connection attempt fails. So I need to destroy and recreate the connection to make it use SockJS for the second connection attempt.

@FZambia
Copy link
Member

FZambia commented Sep 10, 2019

Looks like a bug - manually called disconnect should not result into automatic reconnects even if called in already disconnected state, I will try to reproduce it and write back after that.

@FZambia
Copy link
Member

FZambia commented Sep 11, 2019

#93 should fix this

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 a pull request may close this issue.

2 participants