Esempio n. 1
0
    void Start()
    {
        if (theWebComm != null)
        {
            Debug.LogError("attempt to create two WebComm Objects");
            return;
        }

        theWebComm = this;

        face = FaceSingleton.getFace();

        // class-specific start
        memoryContentCache = new MemoryContentCache(face);

        fetchPrefix = new Name(FaceSingleton.getSpaceName()).append(fetchVerb);
        linkPrefix  = new Name(FaceSingleton.getSpaceName()).append(linkVerb);

        FetchInterestHandler fh = new FetchInterestHandler();

        memoryContentCache.registerPrefix(fetchPrefix, fh, fh);

        LinkInterestHandler lh = new LinkInterestHandler(this);

        face.registerPrefix(linkPrefix, lh, lh);
    }
Esempio n. 2
0
    public void expressHintInterest(Name.Component excludeComp = null)
    {
        Name hintName = new Name(prefix);

        hintName.append(this.getStartTimeComponent()).append(producerNameComponents.trackHint);
        Interest hintInterest = new Interest(hintName);



        if (excludeComp != null)
        {
            Exclude exclude = new Exclude();
            exclude.appendAny();
            //		Debug.Log ("   excluding hint num " + excludeComp.toNumber ());
            exclude.appendComponent(excludeComp);
            hintInterest.setExclude(exclude);
        }

        hintInterest.setMustBeFresh(true);
        hintInterest.setInterestLifetimeMilliseconds(config.defaultHintLifetime);
        hintInterest.setChildSelector(1);
        HintHandler handler = new HintHandler(this);

        FaceSingleton.getFace().expressInterest(hintInterest, handler, handler);
    }
Esempio n. 3
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);
        }
    }
Esempio n. 4
0
    // 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);
    }
Esempio n. 5
0
        public void onTimeout(Interest interest)
        {
            string trackId = interest.getName().get(providerOuterInstance.producerNameComponents.trackIdOffset).toEscapedString();

            //	Debug.Log ("TrackHandler timeout for " + trackId);
            try {
                Track t = providerOuterInstance.tracks[trackId];
                if (!t.isDeadFromTimeout())
                {
                    FaceSingleton.getFace().expressInterest(interest, this, this);
                }
            } catch {
                // this is expected- timeout for an culled track
            }
        }
Esempio n. 6
0
    void expressInitialInterest()
    {
        //Debug.Log ("expressInitialInterest: start");
        Interest initialInterest = new Interest(this.prefix);

        initialInterest.setMustBeFresh(true);
        initialInterest.setInterestLifetimeMilliseconds(config.defaultInitialLifetime);
        // for initial interest, the rightMostChild is preferred
        initialInterest.setChildSelector(1);

        InitialDataHandler handler = new InitialDataHandler(this);

//		Debug.Log ("expressInitialInterest: " +  initialInterest.toUri());
        FaceSingleton.getFace().expressInterest(initialInterest, handler, handler);
    }
Esempio n. 7
0
    //fetchTrack
    public void expressInterestForTrack(string trackID, Name.Component excludeComp = null)
    {
        Name trackName = new Name(prefix);

        trackName.append(startTimeComponent).append(producerNameComponents.tracks).append(trackID);           //.append ("0");
        Interest trackInterest = new Interest(trackName);

        if (excludeComp != null)
        {
            Exclude exclude = new Exclude();
            exclude.appendAny();
            exclude.appendComponent(excludeComp);
            trackInterest.setExclude(exclude);
        }


        trackInterest.setMustBeFresh(true);
        trackInterest.setChildSelector(1);
        TrackHandler handler = new TrackHandler(this);

        FaceSingleton.getFace().expressInterest(trackInterest, handler, handler);
    }
Esempio n. 8
0
 public void onTimeout(Interest interest)
 {
     FaceSingleton.getFace().expressInterest(interest, this, this);
 }