Esempio n. 1
0
        internal Connection(ConnectionManager mgr, SocketWrapper sock)
        {
            _manager = mgr;
            _socket  = sock;
            _state   = ConnectionState.Connected;

            _receiveQueue = new Queue <byte[]>();

            _socket.ConnectionError += SocketErrorHandler;
            _socket.SocketError     += SocketNativeErrorHandler;
            _socket.Disconnected    += SocketDisconnectHandler;
            _socket.Received        += ReceiveDataHandler;

            _sendStream = new MemoryStream();

            _connectionEvent    = new ConnectionEventArgs(this);
            _connectionLostArgs = new ConnectionResultArgs(this, ConnectionResult.Unknown);
            _receiveArgs        = new ConnectionReceiveArgs(this, null);

            CustomData = null;

            var threadStart = new ThreadStart(ConnectionThread);

            _connectionThread = new Thread(threadStart, 512 * 1024);
        }
        protected void OnConnectFailed(Connection conn, ConnectionResult result)
        {
            ConnectionResultArgs args = new ConnectionResultArgs(conn, result);

            ConnectFailed?.Invoke(args);
        }