add: 添加下发和撤销证书测试

This commit is contained in:
2020-06-02 14:37:00 +08:00
parent f65bc6575e
commit 0649cc8f35
11 changed files with 80 additions and 16 deletions
+40
View File
@@ -0,0 +1,40 @@
//
// Created by mingj on 2020/6/2.
//
#include <iostream>
#include <ndn-cxx/interest.hpp>
#include <ndn-cxx/face.hpp>
#include <ndn-cxx/data.hpp>
#include "utils/FileUtils.h"
using namespace std;
using namespace ndn;
int main(int argc, char **argv) {
if (argc < 3) {
cout << "Usage : " << argv[0] << " -f <json file path> " << endl;
return -1;
}
Interest::setDefaultCanBePrefix(true);
string jsonStr = FileUtils::readFile2String(argv[2]);;
ndn::Face face;
ndn::Interest interest("/localmanager/mircertification");
interest.setMustBeFresh(true);
interest.setApplicationParameters((uint8_t *) jsonStr.c_str(), jsonStr.size());
face.expressInterest(interest, [=](const Interest &interest1, const Data &data) {
// onData
const auto &content = data.getContent();
string result((const char *) content.value(), content.value_size());
cout << "receive: " << endl << result << endl;
}, [=](const Interest &interest1, const lp::Nack &nack) {
// onNack
cerr << "onNack: " << interest1.toUri() << endl << "reason: " << nack.getReason() << endl;
}, [=](const Interest &interest1) {
// onTimeout
cerr << "onTimeout: " << interest1.toUri() << endl;
});
face.processEvents();
}