mirror of
https://github.com/fluencelabs/tendermint
synced 2025-07-31 04:01:55 +00:00
rpc: subscribe on reconnection (#689)
* rpc: subscribe on reconnection * rpc: fix unit tests
This commit is contained in:
committed by
Zach Ramsay
parent
b61f5482d4
commit
ce36a0111a
@@ -305,6 +305,14 @@ func (w *WSEvents) RemoveListener(listenerID string) {
|
||||
w.EventSwitch.RemoveListener(listenerID)
|
||||
}
|
||||
|
||||
// After being reconnected, it is necessary to redo subscription
|
||||
// to server otherwise no data will be automatically received
|
||||
func (w *WSEvents) redoSubscriptions() {
|
||||
for event, _ := range w.evtCount {
|
||||
w.subscribe(event)
|
||||
}
|
||||
}
|
||||
|
||||
// eventListener is an infinite loop pulling all websocket events
|
||||
// and pushing them to the EventSwitch.
|
||||
//
|
||||
@@ -327,6 +335,8 @@ func (w *WSEvents) eventListener() {
|
||||
// before cleaning up the w.ws stuff
|
||||
w.done <- true
|
||||
return
|
||||
case <-w.ws.ReconnectCh:
|
||||
w.redoSubscriptions()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user