/// <summary> /// Constructs new server player data given ID, name, auth key and reference of authorized list. /// </summary> /// <param name="id">The ID of the player.</param> /// <param name="ipAddress">The IP address of the client as a string.</param> /// <param name="username">The username of the player.</param> /// <param name="authKey">The authentication key of the player.</param> /// <param name="authorizedList">A reference to the authorized list of the server.</param> public ServerPlayerData( ushort id, string ipAddress, string username, string authKey, AuthKeyList authorizedList ) { Id = id; IpAddressString = ipAddress; Username = username; AuthKey = authKey; _authorizedList = authorizedList; }
/// <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; }
public AuthorizeCommand(AuthKeyList authorizedList, ServerManager serverManager) { _authorizedList = authorizedList; _serverManager = serverManager; }