Exemplo n.º 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();
        }
Exemplo n.º 2
0
 public TCPRequest(string ip, ushort port)
 {
     _channel                        = new TCPConnection(ip, port);
     _channel.OnReceive             += OnReceive;
     _channel.OnConnectionException += OnException;
 }
Exemplo n.º 3
0
 public TCPRequest(string address)
 {
     _channel                        = new TCPConnection(address);
     _channel.OnReceive             += OnReceive;
     _channel.OnConnectionException += OnException;
 }