public void onTimeout(Interest interest)
        {
            //logTextBox.text += "\n" + "Time out for interest " + interest.getName().toUri();
            //logTextBox.text += "\n";

            Interest statusInterest = new Interest(new Name("icear/beacon/status"));

            statusInterest.setInterestLifetimeMilliseconds(2000);

            var onStatusData    = new onStatusDataClass(logTextBox, mNotifyScript, mFace);
            var onStatusTimeout = new onStatusTimeoutClass(logTextBox, mFace, mNotifyScript);

            mFace.expressInterest(statusInterest, onStatusData, onStatusTimeout);
        }
Esempio n. 2
0
        onData(Interest interest, Data data)
        {
            //logTextBox.text += "\n" + "Got a status data packet with name " + data.getName().toUri();

            if (KeyChain.verifyDataWithHmacWithSha256(data, new Blob(hmacKey)))
            {
                //logTextBox.text += "\n" + "Successfully verified data";
            }
            else
            {
                logTextBox.text += "\n" + "Failed to verify incoming data packet, ignoring it...";
                logTextBox.text += "\n" + "Data name: " + data.getName().ToString();
            }

            var content       = data.getContent().buf();
            var contentString = "";

            for (int i = content.position(); i < content.limit(); ++i)
            {
                contentString += (char)content.get(i);
            }
            logTextBox.text += "\n" + "Data name: " + data.getName().ToString();
            logTextBox.text += "\n" + "Data content:";
            logTextBox.text += "\n" + "-------------";
            logTextBox.text += "\n" + contentString;
            logTextBox.text += "\n" + "---------------------------------";
            logTextBox.text += "\n";

            mNotifyScript.updateBeaconListText(contentString);

            if (!contentString.Equals(lastDataContent))
            {
                mNotifyScript.notifyUserOfBeaconListChange();
            }

            Interest statusInterest = new Interest(interest.getName());

            statusInterest.setInterestLifetimeMilliseconds(2000);

            var onStatusData    = new onStatusDataClass(logTextBox, mNotifyScript, mFace);
            var onStatusTimeout = new onStatusTimeoutClass(logTextBox, mFace, mNotifyScript);

            mFace.expressInterest(statusInterest, onStatusData, onStatusTimeout);

            lastDataContent = contentString;
        }
    // Use this for initialization
    void Start()
    {
        // this is here to force the orientation of the app; the UI looks funny if it goes into vertical mode
        Screen.orientation = ScreenOrientation.LandscapeRight;

        showNotificationScript = GetComponent <ShowTextForAFewSeconds>();

        onStatusData    = new onStatusDataClass(logTextBox, showNotificationScript, face);
        onStatusTimeout = new onStatusTimeoutClass(logTextBox, face, showNotificationScript);

        try
        {
            face = new Face
                       (new TcpTransport(), new TcpTransport.ConnectionInfo("127.0.0.1"));
        }
        catch (Exception e)
        {
            logTextBox.text += "\n" + "exception: " + e.Message;
        }
    }
    // Update is called once per frame
    void Update()
    {
        face.processEvents();

        if (firstUpdateLoop)
        {
            Interest statusInterest = new Interest(new Name("icear/beacon/status"));
            statusInterest.setInterestLifetimeMilliseconds(2000);

            var onStatusData    = new onStatusDataClass(logTextBox, showNotificationScript, face);
            var onStatusTimeout = new onStatusTimeoutClass(logTextBox, face, showNotificationScript);

            face.expressInterest(statusInterest, onStatusData, onStatusTimeout);

            firstUpdateLoop = false;
        }

        // We need to sleep for a few milliseconds so we don't use 100% of the CPU.

        System.Threading.Thread.Sleep(5);
    }