Пример #1
0
        public TcpSocketSaeaServer(IPEndPoint listenedEndPoint, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
        {
            if (listenedEndPoint == null)
            {
                throw new ArgumentNullException("listenedEndPoint");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

            this.ListenedEndPoint = listenedEndPoint;
            _dispatcher           = dispatcher;
            _configuration        = configuration ?? new TcpSocketSaeaServerConfiguration();

            if (_configuration.BufferManager == null)
            {
                throw new InvalidProgramException("The buffer manager in configuration cannot be null.");
            }
            if (_configuration.FrameBuilder == null)
            {
                throw new InvalidProgramException("The frame handler in configuration cannot be null.");
            }

            Initialize();
        }
Пример #2
0
        public TcpSocketSaeaSession(
            TcpSocketSaeaServerConfiguration configuration,
            IBufferManager bufferManager,
            SaeaPool saeaPool,
            ITcpSocketSaeaServerMessageDispatcher dispatcher,
            TcpSocketSaeaServer server)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");
            if (bufferManager == null)
                throw new ArgumentNullException("bufferManager");
            if (saeaPool == null)
                throw new ArgumentNullException("saeaPool");
            if (dispatcher == null)
                throw new ArgumentNullException("dispatcher");
            if (server == null)
                throw new ArgumentNullException("server");

            _configuration = configuration;
            _bufferManager = bufferManager;
            _saeaPool = saeaPool;
            _dispatcher = dispatcher;
            _server = server;

            _receiveBuffer = _bufferManager.BorrowBuffer();
            _sessionBuffer = _bufferManager.BorrowBuffer();
            _sessionBufferCount = 0;
        }
Пример #3
0
 public TcpSocketSaeaServer(
     IPAddress listenedAddress, int listenedPort,
     Func <TcpSocketSaeaSession, byte[], int, int, Task> onSessionDataReceived = null,
     Func <TcpSocketSaeaSession, Task> onSessionStarted = null,
     Func <TcpSocketSaeaSession, Task> onSessionClosed  = null,
     TcpSocketSaeaServerConfiguration configuration     = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), onSessionDataReceived, onSessionStarted, onSessionClosed, configuration)
 {
 }
Пример #4
0
 public TcpSocketSaeaServer(
     IPAddress listenedAddress, int listenedPort,
     Func<TcpSocketSaeaSession, byte[], int, int, Task> onSessionDataReceived = null,
     Func<TcpSocketSaeaSession, Task> onSessionStarted = null,
     Func<TcpSocketSaeaSession, Task> onSessionClosed = null,
     TcpSocketSaeaServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), onSessionDataReceived, onSessionStarted, onSessionClosed, configuration)
 {
 }
Пример #5
0
 public TcpSocketSaeaServer(
     IPEndPoint listenedEndPoint,
     Func <TcpSocketSaeaSession, byte[], int, int, Task> onSessionDataReceived = null,
     Func <TcpSocketSaeaSession, Task> onSessionStarted = null,
     Func <TcpSocketSaeaSession, Task> onSessionClosed  = null,
     TcpSocketSaeaServerConfiguration configuration     = null)
     : this(listenedEndPoint,
            new InternalTcpSocketSaeaServerMessageDispatcherImplementation(onSessionDataReceived, onSessionStarted, onSessionClosed),
            configuration)
 {
 }
Пример #6
0
 public TcpSocketSaeaServer(
     IPEndPoint listenedEndPoint,
     Func <TcpSocketSaeaSession, byte[], int, int, Task> onSessionDataReceived = null,
     Func <TcpSocketSaeaSession, Task> onSessionStarted = null,
     Func <TcpSocketSaeaSession, Task> onSessionClosed  = null,
     TcpSocketSaeaServerConfiguration configuration     = null)
     : this(listenedEndPoint,
            new DefaultTcpSocketSaeaServerEventDispatcher(onSessionDataReceived, onSessionStarted, onSessionClosed),
            configuration)
 {
 }
Пример #7
0
        public TcpSocketSaeaServer(IPEndPoint listenedEndPoint, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
        {
            if (listenedEndPoint == null)
                throw new ArgumentNullException("listenedEndPoint");
            if (dispatcher == null)
                throw new ArgumentNullException("dispatcher");

            this.ListenedEndPoint = listenedEndPoint;
            _dispatcher = dispatcher;
            _configuration = configuration ?? new TcpSocketSaeaServerConfiguration();

            if (_configuration.FrameBuilder == null)
                throw new InvalidProgramException("The frame handler in configuration cannot be null.");

            Initialize();
        }
Пример #8
0
        public TcpSocketSaeaSession(
            TcpSocketSaeaServerConfiguration configuration,
            ISegmentBufferManager bufferManager,
            SaeaPool saeaPool,
            ITcpSocketSaeaServerMessageDispatcher dispatcher,
            TcpSocketSaeaServer server)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }
            if (saeaPool == null)
            {
                throw new ArgumentNullException("saeaPool");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            _configuration = configuration;
            _bufferManager = bufferManager;
            _saeaPool      = saeaPool;
            _dispatcher    = dispatcher;
            _server        = server;

            if (_receiveBuffer == default(ArraySegment <byte>))
            {
                _receiveBuffer = _bufferManager.BorrowBuffer();
            }
            _receiveBufferOffset = 0;
        }
Пример #9
0
        public TcpSocketSaeaSession(
            TcpSocketSaeaServerConfiguration configuration,
            IBufferManager bufferManager,
            SaeaPool saeaPool,
            ITcpSocketSaeaServerMessageDispatcher dispatcher,
            TcpSocketSaeaServer server)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }
            if (saeaPool == null)
            {
                throw new ArgumentNullException("saeaPool");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            _configuration = configuration;
            _bufferManager = bufferManager;
            _saeaPool      = saeaPool;
            _dispatcher    = dispatcher;
            _server        = server;

            _receiveBuffer      = _bufferManager.BorrowBuffer();
            _sessionBuffer      = _bufferManager.BorrowBuffer();
            _sessionBufferCount = 0;
        }
Пример #10
0
 public TcpSocketSaeaServer(IPAddress listenedAddress, int listenedPort, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), dispatcher, configuration)
 {
 }
Пример #11
0
 public TcpSocketSaeaServer(int listenedPort, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, dispatcher, configuration)
 {
 }
Пример #12
0
 public TcpSocketSaeaServer(
     IPEndPoint listenedEndPoint,
     Func<TcpSocketSaeaSession, byte[], int, int, Task> onSessionDataReceived = null,
     Func<TcpSocketSaeaSession, Task> onSessionStarted = null,
     Func<TcpSocketSaeaSession, Task> onSessionClosed = null,
     TcpSocketSaeaServerConfiguration configuration = null)
     : this(listenedEndPoint,
           new InternalTcpSocketSaeaServerMessageDispatcherImplementation(onSessionDataReceived, onSessionStarted, onSessionClosed),
           configuration)
 {
 }
Пример #13
0
 public TcpSocketSaeaServer(IPAddress listenedAddress, int listenedPort, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), dispatcher, configuration)
 {
 }
Пример #14
0
 public TcpSocketSaeaServer(int listenedPort, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, dispatcher, configuration)
 {
 }