send heartbeat with ping. (#16)

This commit is contained in:
Miroslav Šedivý 2022-11-11 17:58:54 +01:00 committed by GitHub
parent 482476489e
commit 2cb64d15a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

View file

@ -75,6 +75,13 @@ func (peer *WebSocketPeerCtx) Ping() error {
return errors.New("peer connection not found")
}
// application level heartbeat
if err := peer.connection.WriteJSON(types.WebSocketMessage{
Event: event.SYSTEM_HEARTBEAT,
}); err != nil {
return err
}
return peer.connection.WriteMessage(websocket.PingMessage, nil)
}