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() {
|
go func() {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
for {
|
for {
|
||||||
_, message, err := c.ReadMessage()
|
mt, message, err := c.ReadMessage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("read:", err)
|
log.Println("read:", err)
|
||||||
return
|
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)
|
log.Println("read:", err)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
log.Printf("recv: %s", message)
|
|
||||||
|
log.Printf("recv: %s, type: %s", message, websocket.FormatMessageType(mt))
|
||||||
err = c.WriteMessage(mt, message)
|
err = c.WriteMessage(mt, message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("write:", err)
|
log.Println("write:", err)
|
||||||
|
|
Loading…
Reference in New Issue