improvement websocket according to gorilla example

This commit is contained in:
Adrian Zürcher
2025-06-22 07:46:24 +02:00
parent 659cbe4072
commit 91ea59ed6e
6 changed files with 131 additions and 66 deletions

View File

@@ -20,6 +20,7 @@ func (d *DBMHandler) Set(req *json_dataModels.Request, id string) {
for _, set := range req.Set {
dps := d.DBM.QueryDatapoints(1, set.Uuid, set.Path)
if len(dps) == 0 {
resp.SetError()
if resp.Message == "" {
@@ -27,8 +28,10 @@ func (d *DBMHandler) Set(req *json_dataModels.Request, id string) {
}
continue
}
for _, dp := range dps {
dp.UpdateValue(d.Conns, set.Value)
resp.AddSet(json_dataModels.Set{
Uuid: dp.Uuid,
Path: dp.Path,
@@ -36,6 +39,7 @@ func (d *DBMHandler) Set(req *json_dataModels.Request, id string) {
})
}
}
if err := d.Conns.SendResponse(id, resp); err != nil {
d.Log.Error("get.Set", err.Error())
}