use BaseService.OnReset method to recreate channels

This commit is contained in:
Anton Kaliaev 2017-03-28 14:01:22 +04:00
parent d6587be7bc
commit b0d2032488
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
1 changed files with 7 additions and 1 deletions

View File

@ -47,16 +47,21 @@ func (wsc *WSClient) String() string {
return wsc.Address + ", " + wsc.Endpoint
}
// OnStart implements cmn.BaseService interface
func (wsc *WSClient) OnStart() error {
wsc.BaseService.OnStart()
err := wsc.dial()
if err != nil {
return err
}
go wsc.receiveEventsRoutine()
return nil
}
// OnReset implements cmn.BaseService interface
func (wsc *WSClient) OnReset() error {
wsc.ResultsCh = make(chan json.RawMessage, wsResultsChannelCapacity)
wsc.ErrorsCh = make(chan error, wsErrorsChannelCapacity)
go wsc.receiveEventsRoutine()
return nil
}
@ -86,6 +91,7 @@ func (wsc *WSClient) dial() error {
return nil
}
// OnStop implements cmn.BaseService interface
func (wsc *WSClient) OnStop() {
wsc.BaseService.OnStop()
// ResultsCh/ErrorsCh is closed in receiveEventsRoutine.