abstract write to websocket and add request id
This commit is contained in:
37
dbm/get.go
Normal file
37
dbm/get.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package dbm
|
||||
|
||||
import (
|
||||
json_data "github.com/tecamino/tecamino-json_data"
|
||||
json_dataModels "github.com/tecamino/tecamino-json_data/models"
|
||||
)
|
||||
|
||||
func (d *DBMHandler) Get(gets []json_dataModels.Get, id, id2 string) {
|
||||
if gets == nil {
|
||||
return
|
||||
}
|
||||
d.RLock()
|
||||
defer d.RUnlock()
|
||||
|
||||
r := json_data.NewResponse()
|
||||
r.Id = id2
|
||||
for _, get := range gets {
|
||||
var depth uint = 1
|
||||
if get.Query != nil {
|
||||
depth = get.Query.Depth
|
||||
}
|
||||
|
||||
for _, dp := range d.DB.QueryDatapoints(depth, get.Path) {
|
||||
r.AddGet(json_dataModels.Get{
|
||||
Uuid: dp.Uuid,
|
||||
Path: dp.Path,
|
||||
Type: dp.Type,
|
||||
Value: dp.Value,
|
||||
Rights: dp.ReadWrite,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if err := d.Conns.SendResponse(id, r); err != nil {
|
||||
d.Log.Error("get.Get", err.Error())
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user