mirror of https://github.com/gorilla/websocket.git
feat: format message type
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
This commit is contained in:
parent
0cfb2cafd0
commit
d293aa53e1
|
@ -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))
|
||||
}
|
||||
}()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue