public static HostClient ForClient(TcpClient client) { HostClient new_client = new HostClient(); new_client.tcp_client = client; return(new_client); }
private void AcceptClient(IAsyncResult ar) { var listener = (ar.AsyncState as TcpListener); var new_client = listener.EndAcceptTcpClient(ar); listener.BeginAcceptSocket(new AsyncCallback(AcceptClient), listener); var client = HostClient.ForClient(new_client); if (!Hosts.TryAdd(client.Identifier, client)) { client.Disconnect(); } }