How can i know when nakama is using Rest api or open sockets?

In Unity, nakama has 2 main classes.

client and socket.

many features are directly accessible from the client class and some real-time features from the socket.

in the nakama, client class features has no callbacks. so it probably means its totally stateless. for example, the project, asked for friends features to notify another friend when a person is online or offline.
while the friends feature is accessible through client class I think its not supported and clients should refresh their list with rest API and client class periodically. right?

another question is when a friend is detected online? when it has an open socket on the server?

Hello @virtouso,

The Client functions make use of the Nakama REST APIs, whilst Socket makes use of a realtime connection.

For friends, typically you’d fetch them at client startup and then make use of updates via the callbacks coming from the socket connection (adding a friend will automatically send them a realtime notification). We have a guide here.

Yes, a user is considered online when they’ve established a socket connection with the server (unless they make themselves invisible).

Hope this clarifies.

1 Like