Browse Source

WsjasonReceive hat jetzt einen error Rückgabewert

test
Klaus Wendel 2 years ago
parent
commit
03b9dace16
  1. 8
      nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

8
nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

@ -2,7 +2,6 @@ package nhooyrioWebsocketAddons
import (
"context"
"log"
"nhooyr.io/websocket"
"nhooyr.io/websocket/wsjson"
@ -23,20 +22,19 @@ func WsjsonSend(ctx context.Context, conn *websocket.Conn, sendval interface{})
return nil, receiveval
}
func WsjsonReceive(ctx context.Context, conn *websocket.Conn, dosth func(interface{}) interface{}) {
var err error
func WsjsonReceive(ctx context.Context, conn *websocket.Conn, dosth func(interface{}) interface{}) (err error) {
var sendval, receiveval interface{}
//Receive
err = wsjson.Read(ctx, conn, &receiveval)
if err != nil {
log.Fatalln(err)
return
}
sendval = dosth(receiveval)
//Send
err = wsjson.Write(ctx, conn, sendval.(string))
if err != nil {
log.Fatalln(err)
return
}
}

Loading…
Cancel
Save