Browse Source

GosmContainer-Buffer-Json-Transformation

test
Klaus Wendel 2 years ago
parent
commit
8489580581
  1. 21
      nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

21
nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

@ -2,11 +2,32 @@ package nhooyrioWebsocketAddons
import (
"context"
"encoding/json"
"nhooyr.io/websocket"
"nhooyr.io/websocket/wsjson"
)
type GosmContainerType struct {
TagID string `json:"tagid"`
Attribute string `json:"attribute"` // might left empty
Content string `json:"content"`
}
type GosmContainer []GosmContainerType
func (r *GosmContainer) Gosm2Buffer() (buffer GosmBuffer, err error) {
buffer, err = json.Marshal(*r)
return
}
type GosmBuffer []byte
func (r *GosmBuffer) Buffer2Gosm() (gosm GosmContainer, err error) {
err = json.Unmarshal(*r, &gosm)
return
}
func WsjsonSend(ctx context.Context, conn *websocket.Conn, sendval interface{}) (err error, receiveval interface{}) {
err = nil

Loading…
Cancel
Save