这是indexloc提供的服务,不要输入任何密码
Skip to content

Socket sends all previous messages on retry #30

@Flood

Description

@Flood

Hi!

We are using this web socket implementation. On page load everything is correct and we start sending messages etc. When we loose connection and it gets back again the websocket sends ALL previous messages directly (the messageQueue is empty).

I've commented out this section and now it just creates a new connection without sending anything.

.retryWhen(errors => errors.switchMap(err => {
      // update the connection state to let it know we're retrying
      this.connectionState.next(ConnectionStates.RETRYING);
      
      if(navigator.onLine) {
        // if we have a network connection, try again in 3 seconds
        return Observable.timer(3000);
      } else {
        // if we're offline, so wait for an online event.
        return Observable.fromEvent(window, 'online').take(1);
      }
    }));

How can we make this not send old messages? We still want the retryWhen code since we need to do stuff when we gets back online.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions