The example given here simply does not work.
socket.on_statuspresence(function(message)
local pressences = message.on_status_presence
if pressence then
-- todo: check if online
for _, presence in ipairs(presences)
pprint(presence.username .. " is online with status: '" .. presence.status .. "'")
end
end
end)
on_statuspresence() does not exist on socket. I was able to inspect the socket object and saw on_status_presence_event() which seems to work.
BUT the following also doesn’t work. There is an assertion error on user_ids.
local user_ids = { "<SomeUserId>", "<AnotherUserId>" }
local result = socket.status_follow(user_ids)
Upon inspecting the client sdk source:
function M.status_follow(socket, user_ids, usernames, callback)
assert(socket)
assert(user_ids == nil or _G.type(user_ids) == 'string')
assert(usernames == nil or _G.type(usernames) == 'string')
socket.cid = socket.cid + 1
local message = {
cid = tostring(socket.cid),
status_follow = {
user_ids = user_ids,
usernames = usernames,
}
}
return socket_send(socket, message, callback)
end
The user_ids is expected to be nil or of type string, rather than of type table.
I’ve asked this question in the heroiclabs forum as well, but they hardly answer questions.
Solution: When sending the message manually via socket.send() it works:
local userIdsToFollow = { "86014247-98a7-4f27-8be1-b665f1b09a23", "45196f0b-ae85-4f1e-ac40-f65be6426b65"}
local message = {
status_follow = {
user_ids = userIdsToFollow
}
}
socket.send(message)
I think this is a bug in the client sdk but just wanted to share this in-case I was doing something wrong.
<Rant>
On another note, I trully regret picking Nakama. I have invested too much time at this point to migrate to another backend. Their documentation is out of date for the Defold client. Every time you want to add something, there is a problem like this one. Anyways.
<Rant/>