/// <summary> /// Creates a new LiNGS Server instance. The server starts immediately. /// </summary> /// <exception cref="ArgumentNullException">Thrown when any param is null.</exception> /// <param name="properties">Properties of this server instance. The properties are not changeable at runtime.</param> /// <param name="networkedGame">The instance of your game logic.</param> public LiNGSServer(ServerProperties properties, INetworkedGame networkedGame) { if (properties == null) { throw new ArgumentNullException("Server properties cannot be null."); } if (networkedGame == null) { throw new ArgumentNullException("NetworkedGame cannot be null."); } this.updateManager = new UpdateManager(); ServerProperties = new ServerProperties(properties); NetworkManager = new NetworkManager(this, properties.ListenPort); Manager = new Manager(this, properties.MaxClients); Router = new Router(this); MessageAggregator = new MessageAggregator(this); GameLogicProcessor = new GameLogicProcessor(this); StateManager = new StateManager(this); PersistentStateManager = new PersistentStateManager(this); Analyzer = new Analyzer(this); Dispatcher = new Dispatcher(this); NetworkedGameInstance = networkedGame; this.updateManager.AddUpdatable(MessageAggregator); this.updateManager.AddUpdatable(StateManager); this.updateManager.AddUpdatable(Dispatcher); this.updateManager.AddUpdatable(Manager); this.updateManager.AddUpdatable(Analyzer); this.updateManager.AddUpdatable(GameLogicProcessor); }
/// <summary> /// Creates a new instance of this class with values based on other instance. /// </summary> /// <param name="properties">Existent object</param> public ServerProperties(ServerProperties properties) { this.ListenPort = properties.ListenPort; this.MaxMessageSize = properties.MaxMessageSize; this.MaxClients = properties.MaxClients; this.ImportantMessageTimeout = properties.ImportantMessageTimeout; this.MaxImportantMessageRetries = properties.MaxImportantMessageRetries; this.MaxClientBlackoutTime = properties.MaxClientBlackoutTime; this.MaxMessageWaitTime = properties.MaxMessageWaitTime; this.SessionStorageBaseDirectory = properties.SessionStorageBaseDirectory; this.UseRealClassNames = properties.UseRealClassNames; this.UseSimpleStateManager = properties.UseSimpleStateManager; this.EnablePersistentStates = properties.EnablePersistentStates; this.EnableLog = properties.EnableLog; this.DeleteSessionFilesOnExit = properties.DeleteSessionFilesOnExit; }