/// <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")); }
/// <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); }