mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-03-27 10:12:54 +01:00
29 lines
455 B
Go
29 lines
455 B
Go
package relayer
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/gorilla/websocket"
|
|
)
|
|
|
|
type WebSocket struct {
|
|
conn *websocket.Conn
|
|
mutex sync.Mutex
|
|
|
|
// nip42
|
|
challenge string
|
|
authed string
|
|
}
|
|
|
|
func (ws *WebSocket) WriteJSON(any interface{}) error {
|
|
ws.mutex.Lock()
|
|
defer ws.mutex.Unlock()
|
|
return ws.conn.WriteJSON(any)
|
|
}
|
|
|
|
func (ws *WebSocket) WriteMessage(t int, b []byte) error {
|
|
ws.mutex.Lock()
|
|
defer ws.mutex.Unlock()
|
|
return ws.conn.WriteMessage(t, b)
|
|
}
|