mirror of
https://github.com/nxshock/gron.git
synced 2025-07-14 02:17:26 +05:00
23 lines
336 B
Go
23 lines
336 B
Go
package main
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
type WsConnection struct {
|
|
w *websocket.Conn
|
|
mu sync.Mutex
|
|
}
|
|
|
|
func NewWsConnection(w *websocket.Conn) *WsConnection {
|
|
return &WsConnection{w: w}
|
|
}
|
|
|
|
func (w *WsConnection) Send(message any) error {
|
|
w.mu.Lock()
|
|
defer w.mu.Unlock()
|
|
|
|
return w.w.WriteJSON(message)
|
|
}
|