improve websocket ping and remodel for rename datapoint
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package dbm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@@ -29,6 +30,7 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
|
||||
if get.Query != nil {
|
||||
depth = get.Query.Depth
|
||||
}
|
||||
|
||||
for _, res := range d.DBM.QueryDatapoints(depth, get.Uuid, get.Path) {
|
||||
resp.AddGet(json_dataModels.Get{
|
||||
Uuid: res.Uuid,
|
||||
@@ -44,6 +46,10 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
|
||||
}
|
||||
if len(payload.Set) > 0 {
|
||||
resp.Set, err = d.DBM.CreateDatapoints(payload.Set...)
|
||||
for i, o := range resp.Set {
|
||||
fmt.Println(1000, i, o)
|
||||
fmt.Println(1001, o.HasChild)
|
||||
}
|
||||
if err != nil {
|
||||
r := json_data.NewResponse()
|
||||
r.SetError()
|
||||
@@ -52,6 +58,7 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(200, resp)
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,7 @@ func (d *DBMHandler) Set(req *json_dataModels.Request, id string) {
|
||||
}
|
||||
|
||||
for _, dp := range dps {
|
||||
dp.UpdateValue(d.Conns, set.Value)
|
||||
dp.UpdateValue(set.Value)
|
||||
|
||||
resp.AddSet(json_dataModels.Set{
|
||||
Uuid: dp.Uuid,
|
||||
|
@@ -46,6 +46,10 @@ func (d *DBMHandler) WebSocket(c *gin.Context) {
|
||||
d.Unsubscribe(request, id)
|
||||
}
|
||||
|
||||
client.OnWarning = func(s string) {
|
||||
d.Log.Warning("dbmHandler.webSocket.Websocket", "warning on websocket connection: "+s)
|
||||
}
|
||||
|
||||
client.OnError = func(err error) {
|
||||
d.Log.Error("dbmHandler.webSocket.Websocket", "error on websocket connection: "+err.Error())
|
||||
}
|
||||
|
Reference in New Issue
Block a user