示例#1
0
        private void OnConnected(object sender, SocketAsyncEventArgs e)
        {
            var connected = new TCPConnection(e.AcceptSocket);

            connected.OnConnectionException += (ex) =>
            {
                if (ex is ReceiveMessageConnectionException)
                {
                    connected.Dispose();
                    _connections.Remove(connected);
                }
            };
            _connections.Add(connected);
            try
            {
                OnInboundConnection?.Invoke(connected);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            BeginAccept();
        }
示例#2
0
 public TCPRequest(string ip, ushort port)
 {
     _channel                        = new TCPConnection(ip, port);
     _channel.OnReceive             += OnReceive;
     _channel.OnConnectionException += OnException;
 }
示例#3
0
 public TCPRequest(string address)
 {
     _channel                        = new TCPConnection(address);
     _channel.OnReceive             += OnReceive;
     _channel.OnConnectionException += OnException;
 }