/// <summary> /// This is called on the Server when a Mirror Client disconnects from the Server /// </summary> /// <param name="obj"></param> private void OnMirrorClientDisconnectedEvent(NetworkConnection connection) { MstTimer.WaitForSeconds(0.2f, () => { // Try to find player in filtered list if (roomPlayersByMirrorPeerId.TryGetValue(connection.connectionId, out RoomPlayer player)) { logger.Debug($"Room server player {player.Username} with room client Id {connection.connectionId} left the room"); // Remove thisplayer from filtered list roomPlayersByMirrorPeerId.Remove(player.MirrorPeer.connectionId); roomPlayersByMsfPeerId.Remove(player.MasterPeerId); roomPlayersByUsername.Remove(player.Username); // Notify master server about disconnected player if (RoomController.IsActive) { RoomController.NotifyPlayerLeft(player.MasterPeerId); } // Dispose profile player.Profile?.Dispose(); // Inform subscribers about this bad guy OnPlayerLeftRoomEvent?.Invoke(player); // Calling termination conditions check OnCheckTerminationConditionEvent?.Invoke(); } else { logger.Debug($"Room server client {connection.connectionId} left the room"); } }); }
/// <summary> /// /// </summary> /// <param name="peer"></param> protected override void OnPeerDisconnected(IPeer peer) { MstTimer.WaitForSeconds(0.2f, () => { // Try to find player in filtered list if (roomPlayersByRoomPeerId.TryGetValue(peer.Id, out IRoomPlayerPeerExtension player)) { logger.Debug($"Room server player {player.Username} with room client Id {peer.Id} left the room"); // Remove this player from filtered list roomPlayersByRoomPeerId.Remove(player.Peer.Id); roomPlayersByMsfPeerId.Remove(player.MasterPeerId); roomPlayersByUsername.Remove(player.Username); // Notify master server about disconnected player if (RoomController.IsActive) { RoomController.NotifyPlayerLeft(player.MasterPeerId); } // Inform subscribers about this bad guy OnPlayerLeftRoomEvent?.Invoke(player); // Calling termination conditions check OnCheckTerminationConditionEvent?.Invoke(); } else { logger.Debug($"Room server client {peer.Id} left the room"); } }); }