private void Listen() { Console.WriteLine("Listening for Omicron clients on " + localEndPoint + " (MsgPort: " + msgPort + ")"); while(serverRunning){ listener.Listen(10); // Program is suspended while waiting for an incoming connection. Socket newSocket = listener.Accept(); Client newClient = new Client(newSocket); //Console.WriteLine("Client {0} connected.", newClient.getAddress() ); //Console.WriteLine(" Sending data to client on port {0}", newClient.getDataPort().ToString()); addClient(newClient); Console.WriteLine(" Clients now connected: {0}", clients.Count); } }
public void addClient(String IPaddress, int dataPort) { Client c = new Client(IPaddress, dataPort, outputMode); bool newClient = true; clientLock.WaitOne(); foreach (Client client in clients) { if (client.getDataPort() == c.getDataPort() && client.getAddress() == c.getAddress()) { newClient = false; } }// foreach if (newClient) { clients.Add(c); Console.WriteLine("Manually opened client " + c.getAddress() + ":" + dataPort); switch (outputMode) { case (OutputType.TacTile): Console.WriteLine(" Sending data using TouchAPI (TacTile) format"); break; case (OutputType.Omicron_Legacy): Console.WriteLine(" Sending data using Omicron Legacy format"); break; case (OutputType.Omicron): Console.WriteLine(" Sending data using Omicron format"); break; } } clientLock.Release(); parent.updateClientList(getClientList()); }
private void addClient(Client c) { bool newClient = true; clientLock.WaitOne(); foreach (Client client in clients) { if (client.getDataPort() == c.getDataPort() && client.getAddress() == c.getAddress()) { newClient = false; //Update client Console.WriteLine("Existing client {0}:{1} updated.", c.getAddress(), c.getDataPort() ); client.Update(c); } }// foreach if (newClient) { clients.Add(c); Console.WriteLine("Client {0}:{1} added.", c.getAddress(), c.getDataPort()); switch (c.getDataFormat()) { case (OutputType.TacTile): Console.WriteLine(" Sending data using TouchAPI (TacTile) format"); break; case (OutputType.Omicron_Legacy): Console.WriteLine(" Sending data using Omicron Legacy format"); break; case (OutputType.Omicron): Console.WriteLine(" Sending data using Omicron format"); break; } } clientLock.Release(); parent.updateClientList(getClientList()); }
public void Update(Client c) { if (c.getAddress() == clientAddress && c.getDataPort() == dataPort) { if (dataFormat != c.getDataFormat()) { dataFormat = c.getDataFormat(); //Console.WriteLine("Existing client "+clientAddress+":"+dataPort+" data format updated:"); switch (dataFormat) { case (OmicronServer.OutputType.TacTile): Console.WriteLine(" Requested data using TouchAPI (TacTile) format"); break; case (OmicronServer.OutputType.Omicron_Legacy): Console.WriteLine(" Requested data using Omicron Legacy format"); break; case (OmicronServer.OutputType.Omicron): Console.WriteLine(" Requested data using Omicron format"); break; } } } }