/// <summary> /// Constructs the server manager. /// </summary> /// <param name="netServer">The net server instance.</param> /// <param name="gameSettings">The server game settings.</param> /// <param name="packetManager">The packet manager instance.</param> protected ServerManager( NetServer netServer, Settings.GameSettings gameSettings, PacketManager packetManager ) { _netServer = netServer; GameSettings = gameSettings; _playerData = new ConcurrentDictionary <ushort, ServerPlayerData>(); CommandManager = new ServerCommandManager(); var eventAggregator = new EventAggregator(); var serverApi = new ServerApi(this, CommandManager, _netServer, eventAggregator); AddonManager = new ServerAddonManager(serverApi); // Load the lists _whiteList = WhiteList.LoadFromFile(); _authorizedList = AuthKeyList.LoadFromFile(AuthorizedFileName); _banList = BanList.LoadFromFile(); // Register packet handlers packetManager.RegisterServerPacketHandler <HelloServer>(ServerPacketId.HelloServer, OnHelloServer); packetManager.RegisterServerPacketHandler <ServerPlayerEnterScene>(ServerPacketId.PlayerEnterScene, OnClientEnterScene); packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerLeaveScene, OnClientLeaveScene); packetManager.RegisterServerPacketHandler <PlayerUpdate>(ServerPacketId.PlayerUpdate, OnPlayerUpdate); packetManager.RegisterServerPacketHandler <EntityUpdate>(ServerPacketId.EntityUpdate, OnEntityUpdate); packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerDisconnect, OnPlayerDisconnect); packetManager.RegisterServerPacketHandler(ServerPacketId.PlayerDeath, OnPlayerDeath); packetManager.RegisterServerPacketHandler <ServerPlayerTeamUpdate>(ServerPacketId.PlayerTeamUpdate, OnPlayerTeamUpdate); packetManager.RegisterServerPacketHandler <ServerPlayerSkinUpdate>(ServerPacketId.PlayerSkinUpdate, OnPlayerSkinUpdate); packetManager.RegisterServerPacketHandler <ChatMessage>(ServerPacketId.ChatMessage, OnChatMessage); // Register a timeout handler _netServer.ClientTimeoutEvent += OnClientTimeout; // Register server shutdown handler _netServer.ShutdownEvent += OnServerShutdown; // Register a handler for when a client wants to login _netServer.LoginRequestEvent += OnLoginRequest; }