hub: add guard to WSConn.Ping to ensure no nil conn ptr

This commit is contained in:
henrygd
2026-03-23 15:25:43 -04:00
parent 8e71c8ad97
commit 7a64da9f65

View File

@@ -111,6 +111,9 @@ func (ws *WsConn) Close(msg []byte) {
// Ping sends a ping frame to keep the connection alive.
func (ws *WsConn) Ping() error {
if ws.conn == nil {
return gws.ErrConnClosed
}
ws.conn.SetDeadline(time.Now().Add(deadline))
return ws.conn.WritePing(nil)
}