SocketCluster / socketcluster-client

JavaScript client for SocketCluster
MIT License
293 stars 91 forks source link

Make client disconnect after number of attempts #69

Closed alexus85 closed 7 years ago

alexus85 commented 7 years ago

Just thought it would be great to have an option on client side that defines the maximum number of attempts for the client to keep reconnecting. ( I set 1000 attempts as default. ) . Is it something that could be implemented in the sc-client or is it better approach to have this handled inside my app instead?

jondubois commented 7 years ago

You do that by listening to the connectAbort event and then checking socket.connectAttempts - If it's higher than 1000, you just call socket.disconnect() and it will stop trying to reconnect.

alexus85 commented 7 years ago

I knew there'd be a simpler way to do it. Thanks ! :]