示例#1
0
        private void OnPlayerLeft(IPlayer player, LeaveReasons reason)
        {
            Log.Default.WriteLine(LogLevels.Info, "Player left:{0} {1}", player.Name, reason);

            bool wasServerMaster = false;

            // Remove from player manager
            lock (_playerManager.LockObject)
            {
                if (player == _playerManager.ServerMaster)
                {
                    wasServerMaster = true;
                }
                // Remove player from player list
                _playerManager.Remove(player);
            }

            // Clean host tables
            foreach (IHost host in _hosts)
            {
                host.RemovePlayer(player);
            }

            // If game was running and player was playing, check if only one player left (see GameLostHandler)
            if ((State == ServerStates.GameStarted || State == ServerStates.GamePaused) && player.State == PlayerStates.Playing)
            {
                int playingCount = _playerManager.Players.Count(p => p.State == PlayerStates.Playing);
                if (playingCount == 0 || playingCount == 1)
                {
                    Log.Default.WriteLine(LogLevels.Info, "Game finished by forfeit no winner");
                    State = ServerStates.GameFinished;
                    GameStatistics statistics = PrepareGameStatistics();
                    // Send game finished (no winner)
                    foreach (IEntity entity in Entities.Where(x => x != player))
                    {
                        entity.OnGameFinished(statistics);
                    }
                    State = ServerStates.WaitingStartGame;
                }
            }

            // Inform players and spectators except disconnected player
            foreach (IEntity entity in Entities.Where(x => x != player))
            {
                entity.OnPlayerLeft(player.Id, player.Name, reason);
            }

            // Send new server master id
            if (wasServerMaster)
            {
                IPlayer serverMaster = _playerManager.ServerMaster;
                if (serverMaster != null)
                {
                    foreach (IEntity entity in Entities.Where(x => x != player))
                    {
                        entity.OnServerMasterChanged(serverMaster.Id);
                    }
                }
            }
        }
示例#2
0
 private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason)
 {
     lock (_lock)
     {
         Console.ResetColor();
         Console.SetCursorPosition(_client.Board.Width + 2 + BoardStartX, 2);
         Console.Write("{0} [{1}] left {2}", playerName, playerId, reason);
     }
 }
示例#3
0
 private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason)
 {
     if (Client.IsSpectator)
         return;
     OpponentViewModel opponent = GetOpponentViewModel(playerId);
     if (opponent != null)
     {
         opponent.PlayerId = -1;
         opponent.PlayerName = "Not playing";
         opponent.Team = "";
     }
 }
示例#4
0
        private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason)
        {
            if (!Client.IsSpectator)
            {
                return;
            }

            OpponentViewModel opponent = OpponentsViewModel[playerId];

            if (opponent != null)
            {
                opponent.PlayerId   = -1;
                opponent.PlayerName = "Not playing";
                opponent.Team       = "";
            }
        }
示例#5
0
        private void OnSpectatorLeft(ISpectator spectator, LeaveReasons reason)
        {
            Log.Default.WriteLine(LogLevels.Info, "Spectator left:{0} {1}", spectator.Name, reason);

            // Remove from spectator
            lock (_spectatorManager.LockObject)
            {
                // Remove spectator from spectator list
                _spectatorManager.Remove(spectator);
            }

            // Clean host tables
            foreach (IHost host in _hosts)
            {
                host.RemoveSpectator(spectator);
            }

            // Inform players and spectators except disconnected spectator
            foreach (IEntity entity in Entities.Where(x => x != spectator))
            {
                entity.OnSpectatorLeft(spectator.Id, spectator.Name, reason);
            }
        }
示例#6
0
        private void OnPlayerLeft(int playerid, string playerName, LeaveReasons reason)
        {
            string msg;

            switch (reason)
            {
            case LeaveReasons.Spam:
                msg = String.Format("*** {0} has been BANNED [SPAM]", playerName);
                break;

            case LeaveReasons.Disconnected:
                msg = String.Format("*** {0} has disconnected", playerName);
                break;

            case LeaveReasons.ConnectionLost:
                msg = String.Format("*** {0} has left [connection lost]", playerName);
                break;

            case LeaveReasons.Timeout:
                msg = String.Format("*** {0} has left [timeout]", playerName);
                break;

            case LeaveReasons.Ban:
                msg = String.Format("*** {0} has been BANNED", playerName);
                break;

            case LeaveReasons.Kick:
                msg = String.Format("*** {0} has been kicked", playerName);
                break;

            default:
                msg = String.Format("*** {0} has left {1}", playerName, reason);
                break;
            }
            AddServerMessage(ChatColor.Green, msg);
        }
示例#7
0
 public void OnClientDisconnected(Guid clientId, LeaveReasons reason)
 {
     UpdateCallInfo(System.Reflection.MethodBase.GetCurrentMethod().Name, clientId, reason);
 }
示例#8
0
文件: Admin.cs 项目: SinaC/TetriNET2
        public void OnAdminDisconnected(Guid adminId, LeaveReasons reason)
        {
            _admins.RemoveAll(x => x.Id == adminId);

            AdminDisconnected.Do(x => x(adminId, reason));
        }
示例#9
0
 public void OnAdminDisconnected(Guid adminId, LeaveReasons reason)
 {
     UpdateCallInfo(System.Reflection.MethodBase.GetCurrentMethod().Name, adminId, reason);
 }
示例#10
0
        private static void OnAdminDisconnected(Guid adminId, LeaveReasons reason)
        {
            Console.WriteLine("OnAdminDisconnected: {0} {1}", adminId, reason);

            DisplayAdminList();
        }
示例#11
0
文件: Admin.cs 项目: SinaC/TetriNET2
        public void OnClientDisconnected(Guid clientId, LeaveReasons reason)
        {
            _clients.RemoveAll(x => x.Id == clientId);

            ClientDisconnected.Do(x => x(clientId, reason));
        }
示例#12
0
 public void OnPlayerLeft(int playerId, string name, LeaveReasons reason)
 {
     UpdateCallCount(System.Reflection.MethodBase.GetCurrentMethod().Name);
 }
示例#13
0
文件: Client.cs 项目: SinaC/TetriNET2
        public void OnClientDisconnected(Guid clientId, LeaveReasons reason)
        {
            Log.Default.WriteLine(LogLevels.Info, "Client disconnected {0} {1}", clientId, reason);

            ResetTimeout();

            ClientData clientInGame = _gameClients.FirstOrDefault(x => x.Id == clientId);

            // If client was in game, remove it
            if (clientInGame != null)
            {
                Log.Default.WriteLine(LogLevels.Info, "Client disconnected {0} and removed from game", clientId);

                _gameClients.RemoveAll(x => x.Id == clientId);
                ClientGameLeft.Do(x => x(clientInGame));
            }

            // Remove client
            ClientData client = _clients.FirstOrDefault(x => x.Id == clientId);
            if (client != null)
                _clients.RemoveAll(x => x.Id == clientId);

            ClientDisconnected.Do(x => x(client, reason));
        }
 public void OnSpectatorLeft(int spectatorId, string name, LeaveReasons reason)
 {
     throw new NotImplementedException();
 }
示例#15
0
        private static void OnClientDisconnected(Guid clientId, LeaveReasons reason)
        {
            Console.WriteLine("OnClientDisconnected: {0} {1}", clientId, reason);

            DisplayClientList();
        }
示例#16
0
 public void OnPlayerLeft(int playerId, string name, LeaveReasons reason)
 {
     ExceptionFreeAction(() => Callback.OnPlayerLeft(playerId, name, reason));
 }
示例#17
0
 public void OnPlayerLeft(int playerId, string name, LeaveReasons reason)
 {
     Log.Default.WriteLine(LogLevels.Info, "OnPlayedLeft[{0}]:{1}[{2}] {3}", PlayerName, name, playerId, reason);
     ResetTimeout();
 }
 public void OnAdminDisconnected(Guid adminId, LeaveReasons reason)
 {
     throw new NotImplementedException();
 }
示例#19
0
 private void OnSpectatorLeft(int spectatorId, string spectatorName, LeaveReasons reason)
 {
     DeleteSpectatorEntry(spectatorId, spectatorName);
 }
示例#20
0
 private void OnPlayerLeft(int playerId, string playerName, LeaveReasons reason)
 {
     DeletePlayerEntry(playerId, playerName);
 }
示例#21
0
文件: Client.cs 项目: SinaC/TetriNET2
 public void OnClientDisconnected(Guid clientId, LeaveReasons reason)
 {
     ExceptionFreeAction(() => Callback.OnClientDisconnected(clientId, reason));
 }
示例#22
0
        private void OnClientDisconnected(ClientData client, LeaveReasons reason)
        {
            Console.WriteLine("OnClientDisconnected: {0} {1}", client == null ? Guid.Empty : client.Id, reason);

            DisplayClientList();
        }
示例#23
0
 public void OnSpectatorLeft(int spectatorId, string name, LeaveReasons reason)
 {
     ExceptionFreeAction(() => Callback.OnSpectatorLeft(spectatorId, name, reason));
 }
示例#24
0
 private void OnSpectatorLeft(int spectatorId, string spectatorName, LeaveReasons reason)
 {
     OnPlayerLeft(spectatorId, spectatorName, reason);
 }
示例#25
0
 public void OnSpectatorLeft(int spectatorId, string name, LeaveReasons reason)
 {
     Log.Default.WriteLine(LogLevels.Info, "OnSpectatorLeft[{0}]:{1}[{2}] {3}", PlayerName, name, spectatorId, reason);
 }
 public void OnClientDisconnected(Guid clientId, LeaveReasons reason)
 {
     throw new NotImplementedException();
 }
 public void OnPlayerLeft(int playerId, string name, LeaveReasons reason)
 {
     throw new NotImplementedException();
 }
示例#28
0
文件: Admin.cs 项目: SinaC/TetriNET2
 public void OnAdminDisconnected(Guid adminId, LeaveReasons reason)
 {
     ExceptionFreeAction(() => Callback.OnAdminDisconnected(adminId, reason));
 }