Exemplo n.º 1
0
        public TcpSocketRioSession(
            TcpSocketRioServerConfiguration configuration,
            IBufferManager bufferManager,
            RioConnectionOrientedSocket socket,
            ITcpSocketRioServerMessageDispatcher dispatcher,
            TcpSocketRioServer server)
        {
            if (configuration == null)
                throw new ArgumentNullException("configuration");
            if (bufferManager == null)
                throw new ArgumentNullException("bufferManager");
            if (socket == null)
                throw new ArgumentNullException("socket");
            if (dispatcher == null)
                throw new ArgumentNullException("dispatcher");
            if (server == null)
                throw new ArgumentNullException("server");

            _configuration = configuration;
            _bufferManager = bufferManager;
            _socket = socket;
            _dispatcher = dispatcher;
            _server = server;

            _sessionKey = Guid.NewGuid().ToString();
            this.StartTime = DateTime.UtcNow;

            _receiveBuffer = _bufferManager.BorrowBuffer();
            _sessionBuffer = _bufferManager.BorrowBuffer();
            _sessionBufferCount = 0;

            _stream = new RioStream(_socket);
        }
Exemplo n.º 2
0
        public TcpSocketRioServer(IPEndPoint listenedEndPoint, ITcpSocketRioServerMessageDispatcher dispatcher, TcpSocketRioServerConfiguration configuration = null)
        {
            if (listenedEndPoint == null)
            {
                throw new ArgumentNullException("listenedEndPoint");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }

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

            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();
        }
Exemplo n.º 3
0
        public TcpSocketRioServer(IPEndPoint listenedEndPoint, ITcpSocketRioServerMessageDispatcher dispatcher, TcpSocketRioServerConfiguration configuration = null)
        {
            if (listenedEndPoint == null)
                throw new ArgumentNullException("listenedEndPoint");
            if (dispatcher == null)
                throw new ArgumentNullException("dispatcher");

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

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

            Initialize();
        }
Exemplo n.º 4
0
        public TcpSocketRioSession(
            TcpSocketRioServerConfiguration configuration,
            ISegmentBufferManager bufferManager,
            RioSocket socket,
            ITcpSocketRioServerMessageDispatcher dispatcher,
            TcpSocketRioServer server)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            _configuration = configuration;
            _bufferManager = bufferManager;
            _socket        = socket;
            _dispatcher    = dispatcher;
            _server        = server;

            _sessionKey    = Guid.NewGuid().ToString();
            this.StartTime = DateTime.UtcNow;

            if (_receiveBuffer == default(ArraySegment <byte>))
            {
                _receiveBuffer = _bufferManager.BorrowBuffer();
            }
            _receiveBufferOffset = 0;

            _stream = new RioStream(_socket);
        }
Exemplo n.º 5
0
        public TcpSocketRioSession(
            TcpSocketRioServerConfiguration configuration,
            IBufferManager bufferManager,
            RioConnectionOrientedSocket socket,
            ITcpSocketRioServerMessageDispatcher dispatcher,
            TcpSocketRioServer server)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }
            if (bufferManager == null)
            {
                throw new ArgumentNullException("bufferManager");
            }
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }
            if (dispatcher == null)
            {
                throw new ArgumentNullException("dispatcher");
            }
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            _configuration = configuration;
            _bufferManager = bufferManager;
            _socket        = socket;
            _dispatcher    = dispatcher;
            _server        = server;

            _sessionKey    = Guid.NewGuid().ToString();
            this.StartTime = DateTime.UtcNow;

            _receiveBuffer      = _bufferManager.BorrowBuffer();
            _sessionBuffer      = _bufferManager.BorrowBuffer();
            _sessionBufferCount = 0;

            _stream = new RioStream(_socket);
        }
Exemplo n.º 6
0
 public TcpSocketRioServer(IPAddress listenedAddress, int listenedPort, ITcpSocketRioServerMessageDispatcher dispatcher, TcpSocketRioServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), dispatcher, configuration)
 {
 }
Exemplo n.º 7
0
 public TcpSocketRioServer(int listenedPort, ITcpSocketRioServerMessageDispatcher dispatcher, TcpSocketRioServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, dispatcher, configuration)
 {
 }
Exemplo n.º 8
0
 public TcpSocketRioServer(IPAddress listenedAddress, int listenedPort, ITcpSocketRioServerMessageDispatcher dispatcher, TcpSocketRioServerConfiguration configuration = null)
     : this(new IPEndPoint(listenedAddress, listenedPort), dispatcher, configuration)
 {
 }
Exemplo n.º 9
0
 public TcpSocketRioServer(int listenedPort, ITcpSocketRioServerMessageDispatcher dispatcher, TcpSocketRioServerConfiguration configuration = null)
     : this(IPAddress.Any, listenedPort, dispatcher, configuration)
 {
 }