mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-29 20:51:45 +00:00
rewrite ws client to expose a callback instead of a channel
callback gives more power to the publisher. plus it is optional comparing to a channel, which will block the whole client if you won't read from it.
This commit is contained in:
committed by
Zach Ramsay
parent
ce36a0111a
commit
45ff7cdd0c
@ -226,7 +226,9 @@ func (w *WSEvents) Start() (bool, error) {
|
||||
st, err := w.EventSwitch.Start()
|
||||
// if we did start, then OnStart here...
|
||||
if st && err == nil {
|
||||
ws := rpcclient.NewWSClient(w.remote, w.endpoint)
|
||||
ws := rpcclient.NewWSClient(w.remote, w.endpoint, rpcclient.OnReconnect(func() {
|
||||
w.redoSubscriptions()
|
||||
}))
|
||||
_, err = ws.Start()
|
||||
if err == nil {
|
||||
w.ws = ws
|
||||
@ -335,8 +337,6 @@ 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