コード例 #1
0
    public void onInterest(Name prefix, Interest interest, Face face, long interestFilterId,
                           InterestFilter filter)
    {
        int    linkPrefixSize = webComm.getLinkPrefix().size();
        string phoneId        = interest.getName().get(linkPrefixSize).toEscapedString();
        string linkContent    = interest.getName().get(linkPrefixSize + 1).toEscapedString();

        webComm.handleLink(phoneId, linkContent);

        var data    = new Data(interest.getName());
        var content = "User " + phoneId + " clicked link \"" + linkContent + "\"";

        data.setContent(new Blob(content));
        data.getMetaInfo().setFreshnessPeriod(4000);

        try {
            FaceSingleton.getKeychain().sign(data, FaceSingleton.getCertificateName());
        } catch (SecurityException exception) {
            // Don't expect this to happen.
            throw new SecurityException("SecurityException in sign: " + exception);
        }

        try {
            FaceSingleton.getFace().putData(data);
        } catch (Exception ex) {
            Debug.Log("Echo: Exception in sending data " + ex);
        }
    }
コード例 #2
0
ファイル: NDN_Gyro.cs プロジェクト: yaosiyan/ndn-flow
    // Use this for initialization
    void Start()
    {
        gyroValues       = new Vector3();
        scaledGyroValues = new Vector3();

        // main is static so cannot refer to non-static members here, if want to make onRequestSuccess and onRequestFailed non-static
        AppConsumerTimestamp consumer = new AppConsumerTimestamp(FaceSingleton.getFace(), FaceSingleton.getKeychain(), false);
        ConsumerDataHandler  cdh      = new ConsumerDataHandler(this);

        // todo: fill in simulator prefix
        consumer.consume(new Name(gyroPrefix), cdh, cdh, cdh);
    }