示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GatewayListener{T}"/> class.
 /// </summary>
 /// <param name="logger">A reference to the logger in use.</param>
 /// <param name="options">The options for this listener.</param>
 /// <param name="connectionFactory">A reference to the connection factory in play here.</param>
 /// <param name="dosDefender">A reference to the DoS defender service implementation.</param>
 public GatewayListener(
     ILogger <GatewayListener <TConnectionFactory> > logger,
     IOptions <GatewayListenerOptions> options,
     TConnectionFactory connectionFactory,
     IDoSDefender dosDefender)
     : base(logger, options?.Value, connectionFactory, dosDefender, keepConnectionOpen: false)
 {
 }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameListener{T}"/> class.
 /// </summary>
 /// <param name="logger">A reference to the logger in use.</param>
 /// <param name="options">The options for this listener.</param>
 /// <param name="connectionFactory">A reference to the connection factory in play here.</param>
 /// <param name="dosDefender">A reference to the DoS defender service implementation.</param>
 public GameListener(
     ILogger <GameListener <TConnectionFactory> > logger,
     IOptions <GameListenerOptions> options,
     TConnectionFactory connectionFactory,
     IDoSDefender dosDefender)
     : base(logger, options?.Value, connectionFactory, dosDefender)
 {
 }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameListener{T}"/> class.
 /// </summary>
 /// <param name="logger">A reference to the logger in use.</param>
 /// <param name="options">The options for this listener.</param>
 /// <param name="connectionFactory">A reference to the connection factory in play here.</param>
 /// <param name="dosDefender">A reference to the DoS defender service implementation.</param>
 /// <param name="tcpListener">Optional. An intance to use as the TCP listener, useful for unit testing.</param>
 public GameListener(
     ILogger logger,
     IOptions <GameListenerOptions> options,
     TConnectionFactory connectionFactory,
     IDoSDefender dosDefender,
     ITcpListener tcpListener)
     : base(logger, options?.Value, connectionFactory, dosDefender, keepConnectionOpen: true, tcpListener)
 {
 }
示例#4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseListener"/> class.
        /// </summary>
        /// <param name="port">The port to use on this listener.</param>
        /// <param name="protocol">The protocol to use in this listener.</param>
        /// <param name="dosDefender">A reference to the DoS defender service implementation.</param>
        protected BaseListener(int port, IProtocol protocol, IDoSDefender dosDefender)
            : base(IPAddress.Any, port)
        {
            protocol.ThrowIfNull(nameof(protocol));
            dosDefender.ThrowIfNull(nameof(dosDefender));

            this.protocol = protocol;
            this.defender = dosDefender;
        }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseListener"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="options">The options for this listener.</param>
        /// <param name="socketConnectionFactory">A reference to the socekt connection factory in use.</param>
        /// <param name="dosDefender">A reference to a DoS defender service implementation.</param>
        /// <param name="keepConnectionOpen">Optional. A value indicating whether to maintain the connection open after processing a message in the connection.</param>
        /// <param name="tcpListener">Optional. An intance to use as the TCP listener, useful for unit testing.</param>
        protected BaseListener(ILogger logger, BaseListenerOptions options, ISocketConnectionFactory socketConnectionFactory, IDoSDefender dosDefender, bool keepConnectionOpen = true, ITcpListener tcpListener = null)
        {
            logger.ThrowIfNull(nameof(logger));
            options.ThrowIfNull(nameof(options));
            socketConnectionFactory.ThrowIfNull(nameof(socketConnectionFactory));

            DataAnnotationsValidator.ValidateObjectRecursive(options);

            this.dosDefender             = dosDefender;
            this.keepConnectionOpen      = keepConnectionOpen;
            this.socketConnectionFactory = socketConnectionFactory;

            this.tcpListener = tcpListener ?? new FibulaTcpListener(IPAddress.Any, options?.Port ?? 0);

            this.Logger = logger.ForContext(this.GetType());
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BaseTcpListener"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger in use.</param>
        /// <param name="options">The options for this listener.</param>
        /// <param name="socketConnectionFactory">A reference to the socekt connection factory in use.</param>
        /// <param name="dosDefender">A reference to a DoS defender service implementation.</param>
        /// <param name="keepConnectionOpen">Optional. A value indicating whether to maintain the connection open after processing a message in the connection.</param>
        protected BaseTcpListener(ILogger logger, BaseTcpListenerOptions options, ISocketConnectionFactory socketConnectionFactory, IDoSDefender dosDefender, bool keepConnectionOpen = true)
        {
            logger.ThrowIfNull(nameof(logger));
            options.ThrowIfNull(nameof(options));
            socketConnectionFactory.ThrowIfNull(nameof(socketConnectionFactory));

            DataAnnotationsValidator.ValidateObjectRecursive(options);

            this.dosDefender             = dosDefender;
            this.keepConnectionOpen      = keepConnectionOpen;
            this.socketConnectionFactory = socketConnectionFactory;

            this.internalListener = new TcpListener(IPAddress.Any, options?.Port ?? 0);

            this.Logger = logger;
        }
示例#7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LoginListener"/> class.
 /// </summary>
 /// <param name="protocolFactory">The protocol factory reference to create a protocol that the listerner will follow.</param>
 /// <param name="dosDefender">A reference to the DoS defender service implementation.</param>
 /// <param name="port">The port where this listener will listen.</param>
 public LoginListener(IProtocolFactory protocolFactory, IDoSDefender dosDefender, int port = DefaultLoginListenerPort)
     : base(port, protocolFactory?.CreateForType(OpenTibiaProtocolType.LoginProtocol), dosDefender)
 {
 }
示例#8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ManagementListener"/> class.
 /// </summary>
 /// <param name="protocolFactory">The protocol factory reference to create a protocol that the listerner will follow.</param>
 /// <param name="dosDefender">A reference to the DoS defender service implementation.</param>
 /// <param name="port">The port where this listener will listen.</param>
 public ManagementListener(IProtocolFactory protocolFactory, IDoSDefender dosDefender, int port = DefaultManagementListenerPort)
     : base(port, protocolFactory?.CreateForType(OpenTibiaProtocolType.ManagementProtocol), dosDefender)
 {
 }