recws-org / recws

Reconnecting WebSocket is a websocket client based on gorilla/websocket that will automatically reconnect if the connection is dropped and keeps the connection alive - thread safe!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[proposal] Method to wait for re-connect after connection loss

masseelch opened this issue · comments

Currently I do it this way, but find it rather unclean:

for {
  if !ws.IsConnected() {
    time.Sleep(time.Second * 2)
    continue
  }

  // Do stuff with connection
}

One idea I have is to export the getBackoff() method to wait for the correct time until trying to read a new message. Another idea is to have a method WaitConnection() / EnsureConnection(), which blocks until the connection is reestablished. I am happy to create a PR for either of the proposals.

Is this repo still maintained?