add set parameter in websocket
This commit is contained in:
19
dbm/set.go
Normal file
19
dbm/set.go
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package dbm
|
||||||
|
|
||||||
|
import (
|
||||||
|
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *DBMHandler) Set(sets []json_dataModels.Set) {
|
||||||
|
if sets == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
d.RLock()
|
||||||
|
defer d.RUnlock()
|
||||||
|
|
||||||
|
for _, set := range sets {
|
||||||
|
for _, dp := range d.DB.QueryDatapoints(1, set.Path) {
|
||||||
|
dp.UpdateValue(d.Conns, set.Value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -40,6 +40,9 @@ func (d *DBMHandler) WebSocket(c *gin.Context) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sets
|
||||||
|
go d.Set(request.Set)
|
||||||
|
|
||||||
// Subscribe
|
// Subscribe
|
||||||
go d.Subscribe(request.Subscribe, id)
|
go d.Subscribe(request.Subscribe, id)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user