gorilla/websocket 报错concurrent w

2021-01-11  本文已影响0人  yichen_china

https://sourcegraph.com/github.com/gorilla/websocket@master/-/blob/conn_test.go#L222:16

type WsConn struct {
    *websocket.Conn
    Mux sync.RWMutex
}


wsConn.Mux.Lock() //加锁
    err=wsConn.Conn.WriteMessage(websocket.TextMessage,msgByte)
wsConn.Mux.Unlock() //解锁
上一篇 下一篇

猜你喜欢

热点阅读