felangel / web_socket_client

A simple WebSocket client for Dart which includes automatic reconnection logic.
https://pub.dev/packages/web_socket_client
MIT License
150 stars 32 forks source link

feat: Reconnecting state close code #50

Closed artemsorochan closed 3 months ago

artemsorochan commented 4 months ago

Description

Hello, is it possible to receive the close code, once the connection state is "Reconnecting"?

Giving the context, we are passing user's auth token to header when trying to connect to the web-socket. In case the token is invalid, back-end closes connection with specific error code, which mobile should recognize and regenerate the token.

So is it possible to intercept the close code between reconnection attempts by web_socket_client?

felangel commented 3 months ago

You should be able to save the close code from the last disconnected state.

Closing for now but if my suggestion doesn't help let me know and I'm happy to continue the conversation 👍