open result&error channels on start
This commit is contained in:
parent
b0d2032488
commit
ba5382b70e
|
@ -32,12 +32,10 @@ type WSClient struct {
|
||||||
func NewWSClient(remoteAddr, endpoint string) *WSClient {
|
func NewWSClient(remoteAddr, endpoint string) *WSClient {
|
||||||
addr, dialer := makeHTTPDialer(remoteAddr)
|
addr, dialer := makeHTTPDialer(remoteAddr)
|
||||||
wsClient := &WSClient{
|
wsClient := &WSClient{
|
||||||
Address: addr,
|
Address: addr,
|
||||||
Dialer: dialer,
|
Dialer: dialer,
|
||||||
Endpoint: endpoint,
|
Endpoint: endpoint,
|
||||||
Conn: nil,
|
Conn: nil,
|
||||||
ResultsCh: make(chan json.RawMessage, wsResultsChannelCapacity),
|
|
||||||
ErrorsCh: make(chan error, wsErrorsChannelCapacity),
|
|
||||||
}
|
}
|
||||||
wsClient.BaseService = *cmn.NewBaseService(log, "WSClient", wsClient)
|
wsClient.BaseService = *cmn.NewBaseService(log, "WSClient", wsClient)
|
||||||
return wsClient
|
return wsClient
|
||||||
|
@ -54,14 +52,14 @@ func (wsc *WSClient) OnStart() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
wsc.ResultsCh = make(chan json.RawMessage, wsResultsChannelCapacity)
|
||||||
|
wsc.ErrorsCh = make(chan error, wsErrorsChannelCapacity)
|
||||||
go wsc.receiveEventsRoutine()
|
go wsc.receiveEventsRoutine()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnReset implements cmn.BaseService interface
|
// OnReset implements cmn.BaseService interface
|
||||||
func (wsc *WSClient) OnReset() error {
|
func (wsc *WSClient) OnReset() error {
|
||||||
wsc.ResultsCh = make(chan json.RawMessage, wsResultsChannelCapacity)
|
|
||||||
wsc.ErrorsCh = make(chan error, wsErrorsChannelCapacity)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue