Skip to content

Commit

Permalink
feat: format message type
Browse files Browse the repository at this point in the history
Signed-off-by: rfyiamcool <[email protected]>
  • Loading branch information
rfyiamcool authored and AlexVulaj committed Feb 14, 2024
1 parent 6ba859a commit 95fef26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions examples/echo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ func main() {
go func() {
defer close(done)
for {
_, message, err := c.ReadMessage()
mt, message, err := c.ReadMessage()
if err != nil {
log.Println("read:", err)
return
}
log.Printf("recv: %s", message)
log.Printf("recv: %s, type: %s", message, websocket.FormatMessageType(mt))
}
}()

Expand Down
3 changes: 2 additions & 1 deletion examples/echo/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ func echo(w http.ResponseWriter, r *http.Request) {
log.Println("read:", err)
break
}
log.Printf("recv: %s", message)

log.Printf("recv: %s, type: %s", message, websocket.FormatMessageType(mt))
err = c.WriteMessage(mt, message)
if err != nil {
log.Println("write:", err)
Expand Down

0 comments on commit 95fef26

Please sign in to comment.