Skip to content

Get Connection State #205

Open
@mihai1voicescu

Description

@mihai1voicescu

It would be great if we could listen to the current connection state.

Motivation

Viewing the current connection state is important, especially when using the reconnect feature. This will enable a bunch of new use cases without the need to create a hacky workaround.

Example use case:

  • Client side: Displaying a disconnected message in a chat app
  • Server side: Marking the worker disconnected and not sending any more work to it.
  • Logging so we can debug the rest of the application

Desired solution

Add the possible states and expose them via a StateFlow.

I am open to do a PR if you would like, but I would like a list of possible states 😄 .

As an example:

  • Connecting - Connecting for the first time
  • Connected
  • Disconnected - Has disconnected
  • Reconnecting - Attempting to reconnect, will only be emitted for reconnect version
  • Failed - Closed with an error
  • Closed - Closed normally

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions