Ejemplo n.º 1
0
 /// <summary>
 /// </summary>
 /// <param name="client">
 /// </param>
 public void Add(Client client)
 {
     lock (this.syncLock)
     {
         this.clients.Add(client.ID, client);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// </summary>
        /// <param name="asyncResult">
        /// </param>
        private void OnAcceptTcpClient(IAsyncResult asyncResult)
        {
            if (this.isStopped)
            {
                return;
            }

            this.listener.BeginAcceptTcpClient(this.OnAcceptTcpClient, null);

            TcpClient tcpClient = this.listener.EndAcceptTcpClient(asyncResult);

            var client = new Client(tcpClient);

            this.BeginReceiveClientMessages(
                new ClientMessageReceivedState
                    {
                        MessagePacket = new byte[1024], SerializedMessage = new List<byte>(), Client = client
                    });

            this.clientRegistry.Add(client);

            this.OnClientConnected(client.ID);
        }