Hi,
I am using the server to send messages to client. Specifically i am using the this.matchDispatcher.broadcastMessage
/**
* Broadcast a message to match presences.
*
* @param opcode - Numeric message op code.
* @param data - Opt. Data payload string, or null.
* @param presences - Opt. List of presences (a subset of match participants) to use as message targets, or null to send to the whole match. Defaults to null.
* @param sender - Opt. A presence to tag on the message as the 'sender', or null.
* @param reliable - Opt. Broadcast the message with delivery guarantees or not. Defaults to true.
* @throws {TypeError, GoError}
*/
broadcastMessage(opcode: number, data?: Uint8Array | string | null, presences?: Presence[] | null, sender?: Presence | null, reliable?: boolean): void;
However when i use this where data
is a UInt8Array i get this error:
{"level":"error","ts":"2022-07-14T18:38:23.452Z","caller":"server/runtime_javascript_logger.go:94","msg":"Error%!(EXTRA string=TypeError\n\tat github.com/heroiclabs/nakama/v3/server.(*RuntimeJavaScriptMatchCore).broadcastMessage.func1 (native)\n\tat index.js:7791:76(61)\n\tat github.com/dop251/goja.(*Runtime).boundCallable.func1 (native)\n\tat index.js:8550:45(62)\n\tat github.com/dop251/goja.(*Runtime).boundCallable.func1 (native)\n\tat matchLoop (index.js:8792:63(32))\n\tat native\n)","mid":"506c5ae9-9b7f-49d3-a0a3-87926b5e77a8"}
Here is the transpiled JS code it is erroring on:
Here is the TS code:
It works if i use strings like this:
Is it not possible to send bytes through the socket directly?