Exemplo n.º 1
0
        public void Disconnect()
        {
            MDLog.Info(LOG_CAT, "Disconnected from server");
            IsSessionStarted = false;
            foreach (int PeerId in Players.Keys)
            {
                MDPlayerInfo Player = Players[PeerId];
                OnPlayerLeftEvent(PeerId);
                Player.RemoveAndFree();
            }

            NetworkedMultiplayerENet peer = GetPeer();

            if (peer != null)
            {
                peer.CloseConnection();
                SetNetworkPeer(null);
            }

            StopUPNP();
            Players.Clear();
            ClearNetworkedNodes();
            OnSessionEndedEvent();
            SceneBuffer.Clear();
        }
Exemplo n.º 2
0
 // Removes the MDPlayerInfo belonging to the PeerId
 private void RemovePlayerObject(int PeerId)
 {
     if (Players.ContainsKey(PeerId))
     {
         MDPlayerInfo Player = Players[PeerId];
         PreparePlayerInfoForRemoval(Player);
         Player.RemoveAndFree();
         Players.Remove(PeerId);
     }
 }