Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoginProtocol"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger to use.</param>
        /// <param name="handlerSelector">A reference to the handler selector to use in this protocol.</param>
        /// <param name="protocolConfigOptions">A reference to the protocol configuration options.</param>
        /// <param name="gameConfigOptions">A reference to the game configuration options.</param>
        public LoginProtocol(
            ILogger logger,
            IHandlerSelector handlerSelector,
            ProtocolConfigurationOptions protocolConfigOptions,
            GameConfigurationOptions gameConfigOptions)
            : base(handlerSelector, keepConnectionOpen: false)
        {
            logger.ThrowIfNull(nameof(logger));
            protocolConfigOptions.ThrowIfNull(nameof(protocolConfigOptions));
            gameConfigOptions.ThrowIfNull(nameof(gameConfigOptions));

            this.Logger = logger.ForContext <LoginProtocol>();
            this.ProtocolConfiguration = protocolConfigOptions;
            this.GameConfiguration     = gameConfigOptions;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProtocolFactory"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger to use.</param>
        /// <param name="handlerSelectors">The handler selectors to pass down to the protocol instance.</param>
        /// <param name="gameConfigOptions">A reference to the game configuration options.</param>
        /// <param name="protocolConfigOptions">A referebce to the protocol configuration options.</param>
        public ProtocolFactory(
            ILogger logger,
            IEnumerable <IHandlerSelector> handlerSelectors,
            IOptions <GameConfigurationOptions> gameConfigOptions,
            IOptions <ProtocolConfigurationOptions> protocolConfigOptions)
        {
            logger.ThrowIfNull(nameof(logger));
            handlerSelectors.ThrowIfNull(nameof(handlerSelectors));
            gameConfigOptions.ThrowIfNull(nameof(gameConfigOptions));
            protocolConfigOptions.ThrowIfNull(nameof(protocolConfigOptions));

            this.logger = logger;
            this.handlerSelectorsKnown = handlerSelectors.ToList();
            this.gameConfig            = gameConfigOptions?.Value;
            this.protocolConfig        = protocolConfigOptions?.Value;

            this.protocolInstancesCreated = new Dictionary <OpenTibiaProtocolType, IProtocol>();
            this.protocolCreationLock     = new object();
        }