mirror of
https://github.com/m1k1o/neko.git
synced 2025-06-14 08:42:40 +02:00
muxed socket.send fixes #27
This commit is contained in:
parent
1cf3eee3e6
commit
0d86073f7e
1 changed files with 4 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue