gobwas / ws

Tiny WebSocket library for Go.
MIT License
6.14k stars 376 forks source link

How to handle pong messages with wsutil? #131

Closed lsnow99 closed 3 years ago

lsnow99 commented 3 years ago

Hi, I am using msg, op, err := wsutil.ReadClientData(conn) in a loop to read in all messages from the client. I am sending ping messages from the server, and would like to receive the pong events from the client so I can reset my timer that closes the connection if no pong has been received after x seconds. I see that wsutil seems to just ignore the pong messages. Is there any way to be notified from wsutil that a pong has been received?

sunfuze commented 3 years ago

Using wsutil.NextReader to handle all websocket frame. You can know if frame is control frame or not.