Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameServer" /> class.
        /// </summary>
        /// <param name="gameServerDefinition">The game server definition.</param>
        /// <param name="guildServer">The guild server.</param>
        /// <param name="loginServer">The login server.</param>
        /// <param name="persistenceContextProvider">The persistence context provider.</param>
        /// <param name="friendServer">The friend server.</param>
        /// <param name="stateObserver">The state observer.</param>
        public GameServer(
            GameServerDefinition gameServerDefinition,
            IGuildServer guildServer,
            ILoginServer loginServer,
            IPersistenceContextProvider persistenceContextProvider,
            IFriendServer friendServer,
            IServerStateObserver stateObserver)
        {
            this.Id            = gameServerDefinition.ServerID;
            this.Description   = gameServerDefinition.Description;
            this.stateObserver = stateObserver;

            try
            {
                var mapInitializer = new GameServerMapInitializer(gameServerDefinition, this.Id, stateObserver);
                this.gameContext = new GameServerContext(gameServerDefinition, guildServer, loginServer, friendServer, persistenceContextProvider, stateObserver, mapInitializer);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex);
                throw;
            }

            this.ServerInfo = new GameServerInfoAdapter(this, gameServerDefinition.ServerConfiguration);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameServer" /> class.
        /// </summary>
        /// <param name="gameServerDefinition">The game server definition.</param>
        /// <param name="guildServer">The guild server.</param>
        /// <param name="loginServer">The login server.</param>
        /// <param name="persistenceContextProvider">The persistence context provider.</param>
        /// <param name="friendServer">The friend server.</param>
        /// <param name="loggerFactory">The logger factory.</param>
        /// <param name="plugInManager">The plug in manager.</param>
        public GameServer(
            GameServerDefinition gameServerDefinition,
            IGuildServer guildServer,
            ILoginServer loginServer,
            IPersistenceContextProvider persistenceContextProvider,
            IFriendServer friendServer,
            ILoggerFactory loggerFactory,
            PlugInManager plugInManager)
        {
            this.Id              = gameServerDefinition.ServerID;
            this.Description     = gameServerDefinition.Description;
            this.ConfigurationId = gameServerDefinition.GetId();
            this.logger          = loggerFactory.CreateLogger <GameServer>();
            try
            {
                var mapInitializer = new GameServerMapInitializer(gameServerDefinition, loggerFactory.CreateLogger <GameServerMapInitializer>());
                this.gameContext = new GameServerContext(gameServerDefinition, guildServer, loginServer, friendServer, persistenceContextProvider, mapInitializer, loggerFactory, plugInManager);
                this.gameContext.GameMapCreated += (sender, e) => this.OnPropertyChanged(nameof(this.Context));
                this.gameContext.GameMapRemoved += (sender, e) => this.OnPropertyChanged(nameof(this.Context));
                mapInitializer.PlugInManager     = this.gameContext.PlugInManager;
            }
            catch (Exception ex)
            {
                this.logger.LogCritical(ex, "Error during map initialization");
                throw;
            }

            this.ServerInfo = new GameServerInfoAdapter(this, gameServerDefinition.ServerConfiguration ?? throw new InvalidOperationException("GameServerDefinition requires a ServerConfiguration"));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameServer" /> class.
        /// </summary>
        /// <param name="gameServerDefinition">The game server definition.</param>
        /// <param name="guildServer">The guild server.</param>
        /// <param name="loginServer">The login server.</param>
        /// <param name="persistenceContextProvider">The persistence context provider.</param>
        /// <param name="friendServer">The friend server.</param>
        public GameServer(
            GameServerDefinition gameServerDefinition,
            IGuildServer guildServer,
            ILoginServer loginServer,
            IPersistenceContextProvider persistenceContextProvider,
            IFriendServer friendServer)
        {
            this.Id              = gameServerDefinition.ServerID;
            this.Description     = gameServerDefinition.Description;
            this.ConfigurationId = gameServerDefinition.GetId();

            try
            {
                var mapInitializer = new GameServerMapInitializer(gameServerDefinition, this.Id);
                this.gameContext = new GameServerContext(gameServerDefinition, guildServer, loginServer, friendServer, persistenceContextProvider, mapInitializer);
                this.gameContext.GameMapCreated += (sender, e) => this.OnPropertyChanged(nameof(this.Context));
                this.gameContext.GameMapRemoved += (sender, e) => this.OnPropertyChanged(nameof(this.Context));
                mapInitializer.PlugInManager     = this.gameContext.PlugInManager;
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex);
                throw;
            }

            this.ServerInfo = new GameServerInfoAdapter(this, gameServerDefinition.ServerConfiguration);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameServer"/> class.
        /// </summary>
        /// <param name="gameServerDefinition">The game server definition.</param>
        /// <param name="guildServer">The guild server.</param>
        /// <param name="loginServer">The login server.</param>
        /// <param name="repositoryManager">The repository manager.</param>
        /// <param name="friendServer">The friend server.</param>
        public GameServer(
            GameServerDefinition gameServerDefinition,
            IGuildServer guildServer,
            ILoginServer loginServer,
            IRepositoryManager repositoryManager,
            IFriendServer friendServer)
        {
            this.Id          = gameServerDefinition.ServerID;
            this.Description = gameServerDefinition.Description;

            try
            {
                this.gameContext = new GameServerContext(gameServerDefinition, guildServer, loginServer, friendServer, repositoryManager);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex);
                throw;
            }

            this.freePlayerIds =
                new ConcurrentBag <ushort>(
                    Enumerable.Range(
                        gameServerDefinition.ServerConfiguration.MaximumNPCs + 1,
                        gameServerDefinition.ServerConfiguration.MaximumPlayers).Select(id => (ushort)id));
            this.ServerInfo = new GameServerInfoAdapter(this, gameServerDefinition.ServerConfiguration);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultTcpGameServerListener" /> class.
 /// </summary>
 /// <param name="port">The tcp port.</param>
 /// <param name="gameServerInfo">The game server information.</param>
 /// <param name="gameContext">The game context.</param>
 /// <param name="connectServer">The connect server.</param>
 /// <param name="mainPacketHandler">The main packet handler which should be used by clients which connected through this listener.</param>
 public DefaultTcpGameServerListener(int port, IGameServerInfo gameServerInfo, GameServerContext gameContext, IConnectServer connectServer, IMainPacketHandler mainPacketHandler)
 {
     this.port              = port;
     this.gameServerInfo    = gameServerInfo;
     this.gameContext       = gameContext;
     this.connectServer     = connectServer;
     this.mainPacketHandler = mainPacketHandler;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultTcpGameServerListener" /> class.
 /// </summary>
 /// <param name="endPoint">The endpoint to which this listener is listening.</param>
 /// <param name="gameServerInfo">The game server information.</param>
 /// <param name="gameContext">The game context.</param>
 /// <param name="stateObserver">The connect server.</param>
 /// <param name="addressResolver">The address resolver which returns the address on which the listener will be bound to.</param>
 public DefaultTcpGameServerListener(GameServerEndpoint endPoint, IGameServerInfo gameServerInfo, GameServerContext gameContext, IGameServerStateObserver stateObserver, IIpAddressResolver addressResolver)
 {
     this.endPoint        = endPoint;
     this.gameServerInfo  = gameServerInfo;
     this.gameContext     = gameContext;
     this.stateObserver   = stateObserver;
     this.addressResolver = addressResolver;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultTcpGameServerListener" /> class.
 /// </summary>
 /// <param name="endPoint">The endpoint to which this listener is listening.</param>
 /// <param name="gameServerInfo">The game server information.</param>
 /// <param name="gameContext">The game context.</param>
 /// <param name="connectServer">The connect server.</param>
 /// <param name="addressResolver">The address resolver which returns the address on which the listener will be bound to.</param>
 public DefaultTcpGameServerListener(GameServerEndpoint endPoint, IGameServerInfo gameServerInfo, GameServerContext gameContext, IConnectServer connectServer, IIpAddressResolver addressResolver)
 {
     this.endPoint        = endPoint;
     this.gameServerInfo  = gameServerInfo;
     this.gameContext     = gameContext;
     this.connectServer   = connectServer;
     this.addressResolver = addressResolver;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultTcpGameServerListener" /> class.
 /// </summary>
 /// <param name="endPoint">The endpoint to which this listener is listening.</param>
 /// <param name="gameServerInfo">The game server information.</param>
 /// <param name="gameContext">The game context.</param>
 /// <param name="stateObserver">The connect server.</param>
 /// <param name="addressResolver">The address resolver which returns the address on which the listener will be bound to.</param>
 /// <param name="loggerFactory">The logger factory.</param>
 public DefaultTcpGameServerListener(GameServerEndpoint endPoint, IGameServerInfo gameServerInfo, GameServerContext gameContext, IGameServerStateObserver stateObserver, IIpAddressResolver addressResolver, ILoggerFactory loggerFactory)
 {
     this.endPoint        = endPoint;
     this.gameServerInfo  = gameServerInfo;
     this.gameContext     = gameContext;
     this.stateObserver   = stateObserver;
     this.addressResolver = addressResolver;
     this.loggerFactory   = loggerFactory;
     this.logger          = this.loggerFactory.CreateLogger <DefaultTcpGameServerListener>();
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameServer"/> class.
        /// </summary>
        /// <param name="gameServerDefinition">The game server definition.</param>
        /// <param name="guildServer">The guild server.</param>
        /// <param name="loginServer">The login server.</param>
        /// <param name="repositoryManager">The repository manager.</param>
        /// <param name="friendServer">The friend server.</param>
        public GameServer(
            GameServerDefinition gameServerDefinition,
            IGuildServer guildServer,
            ILoginServer loginServer,
            IRepositoryManager repositoryManager,
            IFriendServer friendServer)
        {
            this.Id          = gameServerDefinition.ServerID;
            this.Description = gameServerDefinition.Description;

            try
            {
                this.gameContext = new GameServerContext(gameServerDefinition, guildServer, loginServer, friendServer, repositoryManager);
            }
            catch (Exception ex)
            {
                Logger.Fatal(ex);
                throw;
            }

            this.ServerInfo = new GameServerInfoAdapter(this, gameServerDefinition.ServerConfiguration);
        }