Following Users is not working

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 use on_status_presence_event() which works.

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 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.

Can someone help me figure this out please?

Hey @SirCez , thank you for flagging these errors in our documentation and SDK. The way you’ve passed in user_ids is correct, we’ll fix the assertion so you can expect that to be patched soon (follow the PR for updates: Fix status_follow and status_unfollow assertions to accept arrays of user IDs by DannyIsYog · Pull Request #91 · heroiclabs/nakama-defold · GitHub)

As for on_statuspresence(), we’ll fix the example in our docs so it uses the right name.

Appreciate your help and patience on this!

2 Likes

Cheers. Thank you for the update and your hard work.