예제 #1
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)
 {
 }
예제 #2
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)
 {
 }
예제 #3
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();
        }
예제 #4
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();
            _receiveBufferOffset = 0;
        }
예제 #5
0
 public TcpSocketSaeaServer(IPAddress listenedAddress, int listenedPort, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), dispatcher, configuration)
 {
 }
예제 #6
0
 public TcpSocketSaeaServer(int listenedPort, ITcpSocketSaeaServerMessageDispatcher dispatcher, TcpSocketSaeaServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, dispatcher, configuration)
 {
 }