You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
380 B
24 lines
380 B
package server |
|
|
|
import ( |
|
"github.com/gorilla/websocket" |
|
"sync" |
|
) |
|
|
|
type wsConn struct { |
|
conn *websocket.Conn |
|
lock *sync.Mutex |
|
} |
|
|
|
func newWsConn(conn *websocket.Conn) *wsConn { |
|
return &wsConn{ |
|
conn: conn, |
|
lock: &sync.Mutex{}, |
|
} |
|
} |
|
|
|
func (c *wsConn) Write(msg []byte) error { |
|
c.lock.Lock() |
|
defer c.lock.Unlock() |
|
return c.conn.WriteMessage(websocket.BinaryMessage, msg) |
|
}
|
|
|