on unity Client there Is Event called “OnPressenceUpdate”. When match is created and the presence is updated, one client receives on single Event with added 2 players to the match but another receives 2 events that on each of them on played has joined.
is there any reason for this or is it just a technical limitation?
_socket.ReceivedMatchPresence += OnMatchPresence;
private void OnMatchPresence(IMatchPresenceEvent message)
{
Debug.LogError($"{message.MatchId} presence updated");
foreach (var item in message.Joins)
{
Debug.LogError($"{item.Username} joined the match. {item.Persistence} {item.Status}");
}
foreach (var item in message.Leaves)
{
Debug.LogError($"{item.Username} left the match {item.Persistence} {item.Status}");
}
}
result of the above code for the first matched user:
cb97c750-d4a4-4c55-87cc-e24dcbe8bcfd. presence updated
vibFUuQxjp joined the match. False
LvpIOPlZSr joined the match. False
result of above code for seconds matched user:
cb97c750-d4a4-4c55-87cc-e24dcbe8bcfd. presence updated
vibFUuQxjp joined the match. False
cb97c750-d4a4-4c55-87cc-e24dcbe8bcfd. presence updated
LvpIOPlZSr joined the match. False
it means the event is called for seconds player 2 times but separately for each players.
So if I understood correctly, the question is why you sometimes see two separate events with a join each, and sometimes a single event with both joins?
This is not an issue nor a technical limitation, but rather an optimization, events can be batched within the same call or not depending on how the server processes them.