Hello, I’m trying to use the streamUserSend API to send a notification to one user. I’ve tried this following:
const l = nk.streamUserGet(ctx.userId, ctx.sessionId, globalStream);
nk.streamSend(globalStream, JSON.stringify({ type: "bot_match", matchId }), [l]);
This gives me the following error:
{"level":"debug","ts":"2025-03-06T14:30:15.933+0400","caller":"server/message_router.go:66","msg":"No session to route to","sid":"00000000-0000-0000-0000-000000000000"}
const l = nk.streamUserList(globalStream);
nk.streamSend(globalStream, JSON.stringify({ type: "bot_match", matchId }), l);
This gives the error:
{"level":"error","ts":"2025-03-06T14:28:02.990+0400","caller":"server/runtime_javascript.go:586","msg":"JavaScript runtime function raised an uncaught exception","mode":"before","id":"*rtapi.envelope_matchmakerremove","error":"TypeError: expects an array of presence objects at github.com/heroiclabs/nakama/v3/server.(*RuntimeJavascriptNakamaModule).mappings.(*RuntimeJavascriptNakamaModule).streamSend.func75 (native)"}
Not sure why this isn’t working. I’m calling this from the beforeMatchmakerRemove hook if that helps.
PS: I’m using streamSend over the Notification API because of the reliable option. Does that matter?
Regards