Browse Source

QuitService->BaseService

pull/456/head
Jae Kwon 8 years ago
parent
commit
161e36fd56
2 changed files with 8 additions and 8 deletions
  1. +4
    -4
      client/ws_client.go
  2. +4
    -4
      server/handlers.go

+ 4
- 4
client/ws_client.go View File

@ -19,7 +19,7 @@ const (
)
type WSClient struct {
QuitService
BaseService
Address string // IP:PORT or /path/to/socket
Endpoint string // /websocket/url/endpoint
Dialer func(string, string) (net.Conn, error)
@ -39,7 +39,7 @@ func NewWSClient(remoteAddr, endpoint string) *WSClient {
ResultsCh: make(chan json.RawMessage, wsResultsChannelCapacity),
ErrorsCh: make(chan error, wsErrorsChannelCapacity),
}
wsClient.QuitService = *NewQuitService(log, "WSClient", wsClient)
wsClient.BaseService = *NewBaseService(log, "WSClient", wsClient)
return wsClient
}
@ -48,7 +48,7 @@ func (wsc *WSClient) String() string {
}
func (wsc *WSClient) OnStart() error {
wsc.QuitService.OnStart()
wsc.BaseService.OnStart()
err := wsc.dial()
if err != nil {
return err
@ -84,7 +84,7 @@ func (wsc *WSClient) dial() error {
}
func (wsc *WSClient) OnStop() {
wsc.QuitService.OnStop()
wsc.BaseService.OnStop()
// ResultsCh/ErrorsCh is closed in receiveEventsRoutine.
}


+ 4
- 4
server/handlers.go View File

@ -264,7 +264,7 @@ const (
// contains listener id, underlying ws connection,
// and the event switch for subscribing to events
type wsConnection struct {
QuitService
BaseService
remoteAddr string
baseConn *websocket.Conn
@ -285,13 +285,13 @@ func NewWSConnection(baseConn *websocket.Conn, funcMap map[string]*RPCFunc, evsw
funcMap: funcMap,
evsw: evsw,
}
wsc.QuitService = *NewQuitService(log, "wsConnection", wsc)
wsc.BaseService = *NewBaseService(log, "wsConnection", wsc)
return wsc
}
// wsc.Start() blocks until the connection closes.
func (wsc *wsConnection) OnStart() error {
wsc.QuitService.OnStart()
wsc.BaseService.OnStart()
// Read subscriptions/unsubscriptions to events
go wsc.readRoutine()
@ -318,7 +318,7 @@ func (wsc *wsConnection) OnStart() error {
}
func (wsc *wsConnection) OnStop() {
wsc.QuitService.OnStop()
wsc.BaseService.OnStop()
wsc.evsw.RemoveListener(wsc.remoteAddr)
wsc.readTimeout.Stop()
wsc.pingTicker.Stop()


Loading…
Cancel
Save