Skip to content

Commit

Permalink
Improve DecodeWSMessage documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
echlebek committed Feb 27, 2024
1 parent a4f31cc commit 5b987ff
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions internal/wsmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// Message header is currently uint64 zero value.
const wsMsgHeader = uint64(0)

// DecodeWSMessage decodes a websocket message as bytes into a proto.Message.
func DecodeWSMessage(bytes []byte, msg proto.Message) error {
// Message header is optional until the end of grace period that ends Feb 1, 2023.
// Check if the header is present.
Expand All @@ -23,9 +24,9 @@ func DecodeWSMessage(bytes []byte, msg proto.Message) error {
}
// Skip the header. It really is just a single zero byte for now.
bytes = bytes[n:]
} /*else {
// Old message format. No header present.
}*/
}
// If no header was present (the "if" check above), then this is the old
// message format. No header is present.

// Decode WebSocket message as a Protobuf message.
err := proto.Unmarshal(bytes, msg)
Expand Down

0 comments on commit 5b987ff

Please sign in to comment.