Exemplo n.º 1
0
 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;
             }
         }
     }
 }
Exemplo n.º 2
0
        public Client(Socket acceptedListener)
        {
            clientID = clientsCreated;
            clientsCreated++;

            udpClient = new UdpClient();
            handler = acceptedListener;

            clientAddress = handler.RemoteEndPoint.ToString();

            // Parses message from TouchAPI for ready signal
            bytes = new byte[1024];
            int bytesRec = handler.Receive(bytes);
            data += Encoding.ASCII.GetString(bytes, 0, bytesRec);
            data = data.Trim();

            // Checks if TouchAPI client is ready to receive data
            if (data.Contains("data_on"))
            {
                // Parse out the dataPort from the data string
                int beginPort = data.IndexOf(',') + 1;
                dataPort = Convert.ToInt32(data.Substring(beginPort, data.Length - beginPort));

                //Console.WriteLine("Client requests data to be sent on port " + dataPort + ".");

                // Parse client address and remove the port, leaving the IPAddress of client
                clientAddress = clientAddress.Substring(0, clientAddress.IndexOf(':'));
                //Console.WriteLine(clientAddress);
                IPAddress clientIP = IPAddress.Parse(clientAddress);

                // Connect to the client's dataport
                udpClient.Connect(clientIP, dataPort);
                active = true;

                if (data.Contains("omicron_legacy_data_on"))
                {
                    dataFormat = OmicronServer.OutputType.Omicron_Legacy;
                    //Console.WriteLine("   " + clientAddress + " requested Omicron legacy data sent on port " + dataPort);
                }
                else if (data.Contains("omicron_data_on"))
                {
                    dataFormat = OmicronServer.OutputType.Omicron;
                    //Console.WriteLine("   " + clientAddress + " requested Omicron data sent on port " + dataPort);
                }
                else
                {
                    dataFormat = OmicronServer.OutputType.Omicron;
                    //Console.WriteLine("   " + clientAddress + " requested TouchAPI data sent on port " + dataPort);
                }
                data = "";
            }
        }
Exemplo n.º 3
0
        public Client(String clientAddr, int dataPrt, OmicronServer.OutputType outputType)
        {
            clientID = clientsCreated;
            clientsCreated++;

            udpClient = new UdpClient();

            // Parse client address and remove the port, leaving the IPAddress of client
            String parsedIP = clientAddr;
            clientAddress = clientAddr;
            dataPort = dataPrt;

            IPAddress clientIP = IPAddress.Parse(parsedIP);
            data = "";

            // Connect to the client's dataport
            udpClient.Connect(clientIP, dataPort);
            active = true;

            switch (outputType)
            {
                case (OmicronServer.OutputType.TacTile):
                    dataFormat = OmicronServer.OutputType.TacTile;
                    break;
                case (OmicronServer.OutputType.Omicron_Legacy):
                    dataFormat = OmicronServer.OutputType.Omicron_Legacy;
                    break;
                case (OmicronServer.OutputType.Omicron):
                    dataFormat = OmicronServer.OutputType.Omicron;
                    break;
            }
        }