ws_client fixes

This commit is contained in:
Jae Kwon
2015-08-04 14:27:46 -07:00
parent 60310cc23f
commit 3949d3f21d
4 changed files with 26 additions and 94 deletions

View File

@ -220,7 +220,7 @@ type WSConnection struct {
baseConn *websocket.Conn
writeChan chan RPCResponse
readTimeout *time.Timer
pingTicker *time.Timer
pingTicker *time.Ticker
funcMap map[string]*RPCFunc
evsw *events.EventSwitch
@ -248,7 +248,7 @@ func (wsc *WSConnection) OnStart() {
// Custom Ping handler to touch readTimeout
wsc.readTimeout = time.NewTimer(time.Second * wsReadTimeoutSeconds)
wsc.pingTicker = time.NewTimer(time.Second * wsPingTickerSeconds)
wsc.pingTicker = time.NewTicker(time.Second * wsPingTickerSeconds)
wsc.baseConn.SetPingHandler(func(m string) error {
wsc.baseConn.WriteControl(websocket.PongMessage, []byte(m), time.Now().Add(time.Second*wsWriteTimeoutSeconds))
wsc.readTimeout.Reset(time.Second * wsReadTimeoutSeconds)