pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.23k stars 199 forks source link

Add a user callback After the minuptime check #186

Open jonenst opened 2 years ago

jonenst commented 2 years ago

It would be nice to be able to run arbitrary user callbacks at the time when the minUptime check succeeds. Currently it only resets the retrycount, but as a user I would like to do things when the websocket becomes considered stable. The callback should be able to know the retrycount value (either get it as an argument, or be called before the reset) to differentiate between normal connections that become stable, and reconnections after failures.

Right now the workaround is to call setTimeout on each 'open' event with the same delay and handle the cancelling of tasks manually.