Reading the documentation and running the following code returns an empty table (no presences).
The below code is ran in an RPC function through the console API explorer page (acting as the system user). Before invoking the RPC, I create a socket connection using the Defold game engine. In the web console status page, I can see there is 1 session and 1 presence.
I was under the impression that when a client is authenticated and a socket session is registered, the user gets added to the notification stream by default. The below code returns no presences. If I add the subject key with the user id to the stream_id object, then it returns a single presence for that user.
In the documentation it states that this should return all players with a session when no subject is passed. Is the documentation wrong or there is a way to get a list of all presences?
local stream_id = { mode = 0 }
local presences = nk.stream_user_list(stream_id)
for _, presence in ipairs(presences) do
nk.logger_info("Found user ID " .. presence.user_id)
end
EDIT: Just to give a bit of context; I am using the Defold game engine with the official nakama client plugin. I’m writing integration tests and I’d like to logout the user and disconnect the socket session after each test to cleanup. In order for me to disconnect a session on the server, I have implemented an RPC endpoint in which I can run nk.session_disconnect() to end a session. But I need to provide the session_id, and the session_id is only available if the RPC is called on the socket. The problem is, the nakama-defold client does not allow you to call an RPC endpoint on the socket.
For the integration tests, I want to disconnect ALL sessions and I thought I could get all presences from the notification stream and disconnect each presence.