mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
muxed socket.send fixes #27
This commit is contained in:
parent
1cf3eee3e6
commit
0d86073f7e
@ -2,6 +2,7 @@ package websocket
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
@ -9,6 +10,7 @@ import (
|
||||
type WebSocket struct {
|
||||
id string
|
||||
connection *websocket.Conn
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func (socket *WebSocket) Address() *string {
|
||||
@ -21,6 +23,8 @@ func (socket *WebSocket) Address() *string {
|
||||
}
|
||||
|
||||
func (socket *WebSocket) Send(v interface{}) error {
|
||||
socket.mu.Lock()
|
||||
defer socket.mu.Unlock()
|
||||
if socket.connection == nil {
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user