예제 #1
0
        public static HostClient ForClient(TcpClient client)
        {
            HostClient new_client = new HostClient();

            new_client.tcp_client = client;
            return(new_client);
        }
예제 #2
0
        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();
            }
        }