Exemplo n.º 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);
        }
    }