Browse Source

GosmContainerBufferAdapter vorbereitet

test
Klaus Wendel 2 years ago
parent
commit
09aa6efc47
  1. 26
      nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

26
nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

@ -8,23 +8,33 @@ import (
"nhooyr.io/websocket/wsjson"
)
type GosmContainerType struct {
type GosmContainerSection struct {
TagID string `json:"tagid"`
Attribute string `json:"attribute"` // might left empty
Content string `json:"content"`
}
type GosmContainer []GosmContainerType
type GosmContainer []GosmContainerSection
func (r *GosmContainer) Gosm2Buffer() (buffer GosmBuffer, err error) {
buffer, err = json.Marshal(*r)
return
type GosmBuffer []byte
type GosmContainerAdapter interface {
revalue(...interface{}) (interface{}, error)
Convert() (GosmBuffer, error)
}
type GosmBuffer []byte
type GosmBufferAdapter interface {
revalue(...interface{}) (interface{}, error)
Convert() (GosmContainer, error)
}
func (r GosmContainer) Convert() (buffer GosmBuffer, err error) {
buffer, err = json.Marshal(r)
return
}
func (r *GosmBuffer) Buffer2Gosm() (gosm GosmContainer, err error) {
err = json.Unmarshal(*r, &gosm)
func (r GosmBuffer) Convert() (gosm GosmContainer, err error) {
err = json.Unmarshal(r, &gosm)
return
}

Loading…
Cancel
Save