Commit 34ba12b2 authored by alexstocks's avatar alexstocks

add conn.go:(gettyWSConn)handlePing & conn.go:(gettyWSConn)handlePong

parent ddb95afc
......@@ -184,11 +184,26 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn {
peer: peerAddr,
},
}
conn.SetPingHandler(gettyWSConn.handlePing)
conn.SetPongHandler(gettyWSConn.handlePong)
return gettyWSConn
}
func (this *gettyWSConn) handlePing(message string) error {
err := this.conn.WriteMessage(websocket.PongMessage, []byte(message))
if err == websocket.ErrCloseSent {
err = nil
} else if e, ok := err.(net.Error); ok && e.Temporary() {
err = nil
}
if err == nil {
this.UpdateActive()
}
return err
}
func (this *gettyWSConn) handlePong(string) error {
this.UpdateActive()
return nil
......
......@@ -11,6 +11,11 @@
## develop history ##
---
- 2016/10/14
> 1 add conn.go:(gettyWSConn)handlePing
>
> 2 add conn.go:(gettyWSConn)handlePong
- 2016/10/13
> 1 add conn.go:(gettyWSConn)writePing which is invoked automatically in session.go:(Session)handleLoop
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment