Skip to content

Commit cfdbc43

Browse files
committed
Improve wspb and wsjson helper subpackages
1 parent 8f01a85 commit cfdbc43

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

wsjson/wsjson.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func read(ctx context.Context, c *websocket.Conn, v interface{}) error {
2929
}
3030

3131
if typ != websocket.MessageText {
32+
c.Close(websocket.StatusUnsupportedData, "can only accept text messages")
3233
return xerrors.Errorf("unexpected frame type for json (expected %v): %v", websocket.MessageText, typ)
3334
}
3435

wspb/wspb.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func read(ctx context.Context, c *websocket.Conn, v proto.Message) error {
3030
}
3131

3232
if typ != websocket.MessageBinary {
33+
c.Close(websocket.StatusUnsupportedData, "can only accept binary messages")
3334
return xerrors.Errorf("unexpected frame type for protobuf (expected %v): %v", websocket.MessageBinary, typ)
3435
}
3536

0 commit comments

Comments
 (0)