Browse Source

GosmAdapter angelegt, aber ich bin von einer endgültigen Lösung noch entfernt

test
Klaus Wendel 2 years ago
parent
commit
18d49ad63e
  1. 51
      nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

51
nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

@ -18,26 +18,55 @@ type GosmContainer []GosmContainerSection
type GosmBuffer []byte
type GosmContainerAdapter interface {
//revalue(...interface{}) (interface{}, error)
Convert() (GosmBuffer, error)
type GosmAdapter interface {
//Revalue(...interface{}) (interface{}, error)
Convert() (GosmAdapter, error)
//WsCommunicator(method string, ctx context.Context, conn *websocket.Conn) (GosmAdapter, error)
}
type GosmBufferAdapter interface {
//revalue(...interface{}) (interface{}, error)
Convert() (GosmContainer, error)
}
func (r GosmContainer) Convert() (GosmAdapter, error) {
buffer, err := json.Marshal(r)
if err != nil {
panic(err)
}
func (r GosmContainer) Convert() (buffer GosmBuffer, err error) {
buffer, err = json.Marshal(r)
return
return GosmBuffer(buffer), err
}
func (r GosmBuffer) Convert() (gosm GosmContainer, err error) {
func (r GosmBuffer) Convert() (i GosmAdapter, err error) {
var gosm GosmContainer
err = json.Unmarshal(r, &gosm)
i = gosm
return
}
/*
func (r GosmContainer) WsCommunicator(method string, ctx context.Context, conn *websocket.Conn) (GosmAdapter, error) {
switch method {
case "json":
WsjsonSend(ctx, conn)
case "bytes":
WsSend()
default:
panic("Wrong communicator method")
}
return GosmBuffer{}, nil
}
func (r GosmBuffer) WsCommunicator(method string, ctx context.Context, conn *websocket.Conn) (GosmAdapter, error) {
switch method {
case "json":
WsjsonReceive()
case "bytes":
WsReceive()
default:
panic("Wrong communicator method")
}
return GosmContainer{}, nil
}
*/
func WsjsonSend(ctx context.Context, conn *websocket.Conn, sendval interface{}) (err error, receiveval interface{}) {
err = nil

Loading…
Cancel
Save