Browse Source

Die Funktion dosth kann jetzt auch nil sein

test
Klaus Wendel 2 years ago
parent
commit
25d8f96096
  1. 10
      nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

10
nhooyrioWebsocketAddons/nhooyrioWebsocketAddons.go

@ -22,8 +22,8 @@ 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{}) (err error, receiveval interface{}) {
var sendval interface{}
func WsjsonReceive(ctx context.Context, conn *websocket.Conn, dosth func(interface{}) interface{}) (err error, sendval interface{}) {
var receiveval interface{}
err = nil
//Receive
@ -31,7 +31,11 @@ func WsjsonReceive(ctx context.Context, conn *websocket.Conn, dosth func(interfa
if err != nil {
return
}
sendval = dosth(receiveval)
if dosth != nil {
sendval = dosth(receiveval)
} else {
sendval = receiveval
}
//Send
err = wsjson.Write(ctx, conn, sendval.(string))

Loading…
Cancel
Save