public void Stop() { if (_server == null || !_running) { return; } _running = false; _server.RoomAdded -= MasterServer_RoomAdded; _server.RoomRemoved -= MasterServer_RoomRemoved; _server.PlayerAdded -= MasterServer_PlayerAdded; _server.VerifyPlayer -= MasterServer_VerifyPlayer; _server.PlayerRemoved -= MasterServer_PlayerRemoved; _server.ConstructNetData -= MasterServer_ConstructNetData; foreach (var item in GetPlayers()) { item.Destroy(); } m_players.Clear(); m_users.Clear(); _server.Shutdown(); _cfg = null; _server = null; Thread.Sleep(100); ServerLogger.LogServer(this, $"Stopped"); }
public void Start() { if (_server != null) { return; } _server = new PNetS.Server(); ReloadCFG(); _server.RoomAdded += MasterServer_RoomAdded; _server.RoomRemoved += MasterServer_RoomRemoved; _server.PlayerAdded += MasterServer_PlayerAdded; _server.VerifyPlayer += MasterServer_VerifyPlayer; _server.PlayerRemoved += MasterServer_PlayerRemoved; _server.ConstructNetData += MasterServer_ConstructNetData; _server.Initialize(_cfg); ServerLogger.LogServer(this, $"Started"); _running = true; }