30 namespace autoconfig {
34 , m_keyChain(keyChain)
35 , m_controller(face, keyChain)
36 , m_nextStageOnFailure(nextStageOnFailure)
44 std::cerr <<
"About to connect to: " << uri << std::endl;
46 faceUri.canonize(bind(&Base::onCanonizeSuccess,
this, _1),
47 bind(&Base::onCanonizeFailure,
this, _1),
48 m_face.getIoService(), time::seconds(4));
54 Base::onCanonizeSuccess(
const FaceUri& canonicalUri)
57 ControlParameters().setUri(canonicalUri.toString()),
58 bind(&Base::onHubConnectSuccess,
this, _1),
59 bind(&Base::onHubConnectError,
this, _1));
63 Base::onCanonizeFailure(
const std::string& reason)
65 BOOST_THROW_EXCEPTION(Error(
"FaceUri canonization failed: " + reason));
69 Base::onHubConnectSuccess(
const ControlParameters& resp)
71 std::cerr <<
"Successfully created face: " << resp << std::endl;
73 static const Name TESTBED_PREFIX =
"/ndn";
74 registerPrefix(TESTBED_PREFIX, resp.getFaceId());
76 static const Name LOCALHOP_NFD_PREFIX =
"/localhop/nfd";
77 registerPrefix(LOCALHOP_NFD_PREFIX, resp.getFaceId());
81 Base::onHubConnectError(
const ControlResponse& response)
83 std::ostringstream os;
84 os <<
"Failed to create face: " << response.getText() <<
" (code: " << response.getCode() <<
")";
85 BOOST_THROW_EXCEPTION(Error(os.str()));
89 Base::registerPrefix(
const Name& prefix, uint64_t faceId)
96 .setOrigin(ndn::nfd::ROUTE_ORIGIN_AUTOCONF)
98 .setExpirationPeriod(time::milliseconds::max()),
99 bind(&Base::onPrefixRegistrationSuccess,
this, _1),
100 bind(&Base::onPrefixRegistrationError,
this, _1));
104 Base::onPrefixRegistrationSuccess(
const ControlParameters& commandSuccessResult)
106 std::cerr <<
"Successful in name registration: " << commandSuccessResult << std::endl;
110 Base::onPrefixRegistrationError(
const ControlResponse& response)
112 BOOST_THROW_EXCEPTION(Error(
"Failed in name registration, " + response.getText() +
113 " (code: " + to_string(response.getCode()) +
")"));
Copyright (c) 2014-2016, Regents of the University of California, Arizona Board of Regents...