public void Stop()
 {
     if (_room == null || !_running)
     {
         return;
     }
     ServersMgr.Remove(this);
     _running = false;
     _room.Shutdown();
     _rLoop.Join();
     Thread.Sleep(50);
     _room.PlayerAdded         -= Room_PlayerAdded;
     _room.PlayerRemoved       -= Room_PlayerRemoved;
     _room.ConstructNetData    -= Room_ConstructNetData;
     _room.ServerStatusChanged -= Room_ServerStatusChanged;
     foreach (var item in _players.Values)
     {
         item.Destroy();
     }
     _players.Clear();
     _objects.Destroy();
     lock (_updatables)
         _updatables.Clear();
     _cfg     = null;
     _room    = null;
     _rLoop   = null;
     _script  = null;
     _objects = null;
 }
 private void Room_ServerStatusChanged()
 {
     if (_room.ServerStatus == ConnectionStatus.Connected)
     {
         ServersMgr.Add(this);
         _id = _room.RoomId.ToString().Normalize(8);
     }
     else
     {
         ServersMgr.Remove(this);
     }
     ServerLogger.LogServer(this, $" Status {_room.ServerStatus}");
 }
Beispiel #3
0
        private void Room_ServerStatusChanged()
        {
            switch (_room.ServerStatus)
            {
            case ConnectionStatus.Connected:
                ServersMgr.Add(this);
                _id = _room.RoomId.ToString().Normalize(8);
                break;

            case ConnectionStatus.Disconnecting:
                ServersMgr.Remove(this);
                break;
            }
            ServerLogger.LogServer(this, $" Status {_room.ServerStatus}");
        }
Beispiel #4
0
 public void Stop()
 {
     if (_room == null || !_running)
     {
         return;
     }
     ServersMgr.Remove(this);
     _running = false;
     _room.Shutdown();
     _rLoop.Join();
     Thread.Sleep(50);
     _room.PlayerAdded         -= Room_PlayerAdded;
     _room.PlayerRemoved       -= Room_PlayerRemoved;
     _room.ConstructNetData    -= Room_ConstructNetData;
     _room.ServerStatusChanged -= Room_ServerStatusChanged;
     _players.Clear();
     _cfg    = null;
     _room   = null;
     _rLoop  = null;
     _script = null;
 }