internal override void HandleParticipantStatusChanged(NativeRealTimeRoom room, GooglePlayGames.Native.PInvoke.MultiplayerParticipant participant) { if (FailedStatuses.Contains(participant.Status())) { mSession.OnGameThreadListener().ParticipantLeft(participant.AsParticipant()); if (room.Status() != Types.RealTimeRoomStatus.CONNECTING && room.Status() != Types.RealTimeRoomStatus.AUTO_MATCHING) { LeaveRoom(); } } }
internal override void HandleConnectedSetChanged(NativeRealTimeRoom room) { HashSet <string> hashSet = new HashSet <string>(); if ((room.Status() == Types.RealTimeRoomStatus.AUTO_MATCHING || room.Status() == Types.RealTimeRoomStatus.CONNECTING) && mSession.MinPlayersToStart <= room.ParticipantCount()) { mSession.MinPlayersToStart += room.ParticipantCount(); mPercentPerParticipant = 80f / (float)(double)mSession.MinPlayersToStart; } foreach (GooglePlayGames.Native.PInvoke.MultiplayerParticipant item in room.Participants()) { using (item) { if (item.IsConnectedToRoom()) { hashSet.Add(item.Id()); } } } if (mConnectedParticipants.Equals(hashSet)) { Logger.w("Received connected set callback with unchanged connected set!"); } else { IEnumerable <string> source = mConnectedParticipants.Except(hashSet); if (room.Status() == Types.RealTimeRoomStatus.DELETED) { Logger.e("Participants disconnected during room setup, failing. Participants were: " + string.Join(",", source.ToArray())); mSession.OnGameThreadListener().RoomConnected(false); mSession.EnterState(new ShutdownState(mSession)); } else { IEnumerable <string> source2 = hashSet.Except(mConnectedParticipants); Logger.d("New participants connected: " + string.Join(",", source2.ToArray())); if (room.Status() == Types.RealTimeRoomStatus.ACTIVE) { Logger.d("Fully connected! Transitioning to active state."); mSession.EnterState(new ActiveState(room, mSession)); mSession.OnGameThreadListener().RoomConnected(true); } else { mPercentComplete += mPercentPerParticipant * (float)source2.Count(); mConnectedParticipants = hashSet; mSession.OnGameThreadListener().RoomSetupProgress(mPercentComplete); } } } }