You may assign a callback to be invoked when a new user joins a room. The callback maybe called on a different server depending on the where the room is and where the new user was.
Diarkis Room allows users to join a room from wherever the user is (the user must be in the same Diarkis cluster).
This means that if the user is connected to the server that does not have the room, Diarkis room will automatically redirect the user to the correct server where the room is.
Rooms has many callbacks that you may use, but we will be talking about SetOnJoinCompleteByID in this article.
SetOnJoinCompleteByID's callback is invoked when a user is successfully joins a room, but if the user is redirected from another server, user reconnecting to the correct server completes the room join operations and SetOnJoinCompleteByID's callback is invoked at that moment.
This callback is invoked on the server that the room exists.
room.SetOnJoinCompleteByID(roomID, func(joinRoomID string, newMember *user.User))
Diagram for room join across 2 servers.
The diagram below shows how a user is reconnected to the server where the room is and where SetOnJoinCompleteByID callback is invoked.
Diagram for room join on a single server
The diagram below shows how use joins a room that exists on the same server as the user.
In this case, the user will not reconnect to another server and SetOnJoinCompleteByID's callback is invoked on the same server.