Exemplo 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);
    }
Exemplo n.º 2
0
    public void start()
    {
        // generic face setup
        face_ = new Face(new TcpTransport(), new TcpTransport.ConnectionInfo(hostName_));

        bootstrap_       = new Bootstrap(face_);
        keyChain_        = bootstrap_.setupDefaultIdentityAndRoot(new Name(instanceName_), new Name());
        certificateName_ = bootstrap_.getDefaultCertificateName();

        // class-specific start
        memoryContentCache_ = new MemoryContentCache(face_);

        fetchPrefix_ = new Name(instanceName_).append(fetchVerb);
        linkPrefix_  = new Name(instanceName_).append(linkVerb);

        FetchInterestHandler fh = new FetchInterestHandler(this);

        memoryContentCache_.registerPrefix(fetchPrefix_, fh, fh);

        LinkInterestHandler lh = new LinkInterestHandler(this);

        face_.registerPrefix(linkPrefix_, lh, lh);

        // publish html content for given mobile, call when needed
        // for this example call this on start
        string htmlString = "<p>Hello world!</p>";
        string mobileName = "/home/browser1";

        publishHtmlForMobile(mobileName, htmlString);

        // update event
        while (true)
        {
            face_.processEvents();
            System.Threading.Thread.Sleep(5);

            // dummy for testing repeated fetch on consumer
            if (nextThreshold_ > 0)
            {
                cycleCount_ += 1;
                if (cycleCount_ > nextThreshold_)
                {
                    htmlString = "<p>" + PhoneHandler.randomString(5) + "</p>";
                    publishHtmlForMobile(mobileName, htmlString);
                    cycleCount_ = 0;
                }
            }
        }
    }