Browse Source

Connection: reconnect on RECONNECT response

Volodymyr Tkach 2 years ago
parent
commit
bcbc5656c6
1 changed files with 8 additions and 1 deletions
  1. 8 1
      pubsub/go_reader.go

+ 8 - 1
pubsub/go_reader.go

@@ -38,7 +38,14 @@ func go_reader(c *Connection) {
 								c.ping_start = ct
 								c.ping_start = ct
 								c.ping_sended = false
 								c.ping_sended = false
 							} else if resp.Type == "RECONNECT" {
 							} else if resp.Type == "RECONNECT" {
-								// TODO: ...
+								c.onInfo("warning, got RECONNECT response")
+								c.active = false
+								c.onDisconnect()
+								c.ping_start = time.Now()
+								c.ping_sended = false
+								if err := c.Connection.Close(); err != nil {
+									c.onError(err)
+								}
 							} else {
 							} else {
 								c.onMessage(msg)
 								c.onMessage(msg)
 							}
 							}