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