Example #1
0
    private static void AcceptConnection(IAsyncResult ar)
    {
        TcpListener listener = (TcpListener)ar.AsyncState;
        TcpClient   client   = hrvServer.EndAcceptTcpClient(ar);

        while (true)
        {
            NetworkStream stream = client.GetStream();
            string        msg    = ReadMessage(stream);
            HRVUpdate     update = new HRVUpdate();
            update.rrMin  = int.Parse(msg.Split(',')[0]);
            update.rrMax  = int.Parse(msg.Split(',')[1]);
            update.rrLast = int.Parse(msg.Split(',')[2]);
            if (Inst.MessageReceived != null)
            {
                Inst.MessageReceived(update);
            }
        }

        //string json = GetMessageFromHTTPPostRequest(msg);


        //HRVMessage hrvMsg = JsonUtility.FromJson<HRVMessage>(json);

        //if (Inst.MessageReceived != null)
        //    Inst.MessageReceived(hrvMsg);

        // wait for next message
        //ConnectToNextClient();
    }
Example #2
0
    void HandleHRVMessage(HRVUpdate update)
    {
        rrMin  = update.rrMin;
        rrMax  = update.rrMax;
        lastRR = update.rrLast;

        /*string msgStr = "Handling hrv message\n";
         * for (int i = 0; i < msg.logs.Count; ++i) {
         *  msgStr += "\t" + msg.logs[i].ts + " " + msg.logs[i].rr + "\n";
         *  HandleRange(msg.logs[i].rr);
         *  lastRR = msg.logs[i].rr;
         * }*/
        //Debug.LogError(msgStr + " " + lastRR + " min: " + rrMin + " max: " + rrMax);
    }
Example #3
0
 void UpdateMetrics(HRVUpdate update)
 {
     rrMin  = update.rrMin;
     rrMax  = update.rrMax;
     lastRR = update.rrLast;
 }