Exemple #1
0
 /// <summary>
 /// Sends to client.
 /// </summary>
 /// <param name="client">Client.</param>
 /// <param name="path">Path.</param>
 public void SendToClient(ConnectingClient client, string path)
 {
     try
     {
         client.Send(path);
     }
     catch (IOException ex)
     {
         OnClientDisconnected(new ClientDisconnectedEventArgs {
             Client = client
         });
     }
 }
Exemple #2
0
 /// <summary>
 /// Sends to client.
 /// </summary>
 /// <param name="client">Client.</param>
 /// <param name="data">Data.</param>
 public void SendToClient(ConnectingClient client, byte[] data)
 {
     try
     {
         client.Send(data);
     }
     catch (IOException ex)
     {
         OnClientDisconnected(new ClientDisconnectedEventArgs {
             Client = client
         });
     }
 }
Exemple #3
0
        private void listenForConnections()
        {
            while (true)
            {
                ConnectingClient client = new ConnectingClient(listener.AcceptTcpClient());
                client.RecieveThread = new Thread(() => listenForMessages(client));
                client.RecieveThread.Start();

                ConnectedClients.Add(client);
                OnClientConnected(new ClientConnectedEventArgs {
                    ConnectingClient = client
                });
            }
        }
Exemple #4
0
 private void listenForMessages(ConnectingClient client)
 {
     try
     {
         while (true)
         {
             OnTextRecieved(new TextRecievedEventArgs {
                 Client = client, Message = client.Input.ReadString()
             });
         }
     }
     catch (IOException ex)
     {
         OnClientDisconnected(new ClientDisconnectedEventArgs {
             Client = client
         });
     }
 }
Exemple #5
0
 /// <summary>
 /// Accepts the client.
 /// </summary>
 /// <param name="client">Client.</param>
 public void AcceptClient(ConnectingClient client)
 {
     AcceptedClients.Add(client);
 }