Exemplo n.º 1
0
 // This function takes in a string and sends it to Python
 public void SendString(string message)
 {
     try
     {
         if (!String.IsNullOrEmpty(message))
         {
             unixSendTimestamp = TimeStamp.ConvertToUnixTimestamp(DateTime.Now);
             message          += "\tTIME " + unixSendTimestamp;
             send_data         = Encoding.UTF8.GetBytes(message);
             pythonSock.SendTo(send_data, pythonEndPoint);
             UDPSendBuffer.Add('"' + message + '"' + "\t" + unixSendTimestamp + "\t" + TimeStamp.ConvertToUnixTimestamp(DateTime.Now) + "\n");
         }
     }
     catch (Exception err)
     {
         print(err.ToString());
     }
 }
Exemplo n.º 2
0
    //********* BV: eyetracker bridge specific??
    // public void RequestData()
    // {
    //  SendString("NEWFRAME");
    // }

    // receive thread
    public void ReceiveData()
    {
        try
        {
            // Bytes empfangen.
            while (client.Available > 0)
            {
                // Data received from Python
                data = client.Receive(ref pythonEndPoint);
                unixRecvTimestamp = TimeStamp.ConvertToUnixTimestamp(DateTime.Now);

                // Convert data to UTF8 string format
                rawtext = Encoding.UTF8.GetString(data);
                UDPReceiveBuffer.Add(rawtext);
            }
            // Added this to reduce Unity CPU% from 100 to 60
//				Thread.Sleep(10);
        }
        catch (Exception err)
        {
            print(err.ToString());
        }
//		}
    }