mirror of
https://github.com/fiatjaf/khatru.git
synced 2025-11-18 18:18:33 +01:00
simplify WriteMessage, remove the defer since it's not needed.
This commit is contained in:
10
websocket.go
10
websocket.go
@@ -33,12 +33,14 @@ type WebSocket struct {
|
|||||||
|
|
||||||
func (ws *WebSocket) WriteJSON(any any) error {
|
func (ws *WebSocket) WriteJSON(any any) error {
|
||||||
ws.mutex.Lock()
|
ws.mutex.Lock()
|
||||||
defer ws.mutex.Unlock()
|
err := ws.conn.WriteJSON(any)
|
||||||
return ws.conn.WriteJSON(any)
|
ws.mutex.Unlock()
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ws *WebSocket) WriteMessage(t int, b []byte) error {
|
func (ws *WebSocket) WriteMessage(t int, b []byte) error {
|
||||||
ws.mutex.Lock()
|
ws.mutex.Lock()
|
||||||
defer ws.mutex.Unlock()
|
err := ws.conn.WriteMessage(t, b)
|
||||||
return ws.conn.WriteMessage(t, b)
|
ws.mutex.Unlock()
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user