Fix panics due to concurrent websocket writes

This commit is contained in:
Lubos Dolezel
2023-02-24 11:49:26 +01:00
parent 8bee96aeff
commit f27cbfb299
21 changed files with 131 additions and 141 deletions

View File

@@ -3,14 +3,13 @@ package services
import (
"context"
"github.com/gorilla/websocket"
ws "saml.dev/gome-assistant/internal/websocket"
)
/* Structs */
type InputText struct {
conn *websocket.Conn
conn *ws.WebsocketWriter
ctx context.Context
}
@@ -24,12 +23,12 @@ func (ib InputText) Set(entityId string, value string) {
"value": value,
}
ws.WriteMessage(req, ib.conn, ib.ctx)
ib.conn.WriteMessage(req, ib.ctx)
}
func (ib InputText) Reload() {
req := NewBaseServiceRequest("")
req.Domain = "input_text"
req.Service = "reload"
ws.WriteMessage(req, ib.conn, ib.ctx)
ib.conn.WriteMessage(req, ib.ctx)
}