예제 #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="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"));
        }
예제 #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="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);
        }
예제 #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);
        }