Esempio n. 1
0
        public void SendHello(ClientDetails visage, Int32 id)
        {
            var message = new ClientHelloMessage(id);

            Console.WriteLine("sending hello");
            visage.client.GetStream().BeginWrite(message.GetBytes(), 0, message.Size, new AsyncCallback(SentHello), visage);
        }
Esempio n. 2
0
 private void ClientDisconnected(ClientDetails visage)
 {
     disconnectedClients.Add(visage);
 }
Esempio n. 3
0
 public void ReceiveMessage(ClientDetails details)
 {
     Console.WriteLine("waiting for messages");
     Array.Clear(details.readBuffer,0,ClientDetails.bufferSize);
     details.client.GetStream().BeginRead(details.readBuffer, 0, ClientDetails.bufferSize, new AsyncCallback(GotMessage), details);
 }
Esempio n. 4
0
        private void AcceptConnection(IAsyncResult ar)
        {
            var client = listener.EndAcceptTcpClient(ar);

            if (clientDetails.Count < maxClients) {
                Console.WriteLine("client connected");

                var visage = new ClientDetails() {client = client};
                clientDetails.Add(visage);
                Int32 id = idcount++;

                SendHello(visage, id);
                AcceptClient();
            } else {
                //too many clients
            }
        }