Hi pro,
I am back again. Got some issues during developing a custom RPC function.
It’s about the streaming service. While joining the stream, I use ctx.sessionId
to get the session id but get undefined
. And add user to stream requires attaching a session id (can be sent manually during request rpc function, but why?)
This is my code for joining stream:
function playerJoinStream(ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, payload: any) {
try {
let streamId: nkruntime.Stream = joinStreamId;
logger.info("*+*+*+*+*+*+*+")
logger.info("trigger player join stream");
logger.info("ctx json:" + JSON.stringify(ctx));
// logger.info("ctx.sessionId:" + ctx.sessionId);
logger.info("trigger player join stream");
logger.info("*+*+*+*+*+*+*+")
nk.streamUserJoin(ctx.userId, ctx.sessionId, streamId);
} catch (error) {
logger.info(JSON.stringify(error))
}
}
and this is the log
nakama_1 | {"level":"info","ts":"2022-06-01T09:12:31.201Z","caller":"server/runtime_javascript_logger.go:68","msg":"*+*+*+*+*+*+*+"}
nakama_1 | {"level":"info","ts":"2022-06-01T09:12:31.202Z","caller":"server/runtime_javascript_logger.go:68","msg":"trigger player join stream"}
nakama_1 | {"level":"info","ts":"2022-06-01T09:12:31.202Z","caller":"server/runtime_javascript_logger.go:68","msg":"ctx json:{\"node\":\"nakama1\",\"env\":{},\"executionMode\":2,\"queryParams\":{},\"userSessionExp\":1654081898,\"userId\":\"188d0185-b8f1-4df6-81c8-8af1d11c6321\",\"username\":\"testtest\",\"clientIp\":\"172.19.0.1\",\"clientPort\":\"63686\"}"}
As the log shows above, ctx not contain the sessionId
.
Is anything I missed out?
Add on details: client is able to join chat channel