Add hook for extending PongHandler

This commit is contained in:
Matt Caldwell
2016-05-08 17:54:50 -04:00
parent 241a6879bf
commit aa4fbf9617
+8 -2
View File
@@ -74,14 +74,20 @@ loop:
}
}
func (s *Session) SetPongHandler(f func() error) {
s.conn.SetPongHandler(func(string) error {
s.conn.SetReadDeadline(time.Now().Add(s.melody.Config.PongWait))
return f()
})
}
func (s *Session) readPump() {
defer s.conn.Close()
s.conn.SetReadLimit(s.melody.Config.MaxMessageSize)
s.conn.SetReadDeadline(time.Now().Add(s.melody.Config.PongWait))
s.conn.SetPongHandler(func(string) error {
s.conn.SetReadDeadline(time.Now().Add(s.melody.Config.PongWait))
s.SetPongHandler(func() error {
return nil
})