private async Task NewConnectionsHandler(AsyncQueue <OwnTcpSendMessage> processQueue) { try { while (IsOpen) { TcpClient client = await listener.AcceptTcpClientAsync().ConfigureAwait(false); OwnTcpSendQueue queue = new OwnTcpSendQueue(); OwnTcpServerConnection connection = new OwnTcpServerConnection(client, queue); connections.Add(connection); Task sendTask = Task.Run(() => SendClientHandler(connection)); Task readTask = Task.Run(() => ReadClientHandler(connection, processQueue)); connection.Task = Task.WhenAll(sendTask, readTask); } } catch (Exception e) { await CloseAsync(e, false); } }
public OwnTcpConnection(TcpClient client) { Client = client; Stream = client.GetStream(); SendQueue = new OwnTcpSendQueue(); }
public OwnTcpServerConnection(TcpClient client, OwnTcpSendQueue sendQueue) : base(client) { }