blob: 5e561ff684d1dbea1d92800e98a8b83a8dc66c0a [file] [log] [blame]
Steve DiBenedetto042bfe92014-01-30 15:05:08 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Named Data Networking Project
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "manager-base.hpp"
8#include "mgmt/app-face.hpp"
9
10#include <ndn-cpp-dev/management/control-response.hpp>
11
12namespace nfd {
13
Steve DiBenedetto3970c892014-01-31 23:31:13 -070014NFD_LOG_INIT("ManagerBase");
15
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070016ManagerBase::ManagerBase(shared_ptr<AppFace> face)
17 : m_face(face)
18{
19
20}
21
22ManagerBase::~ManagerBase()
23{
24
25}
26
27void
28ManagerBase::sendResponse(const Name& name,
29 uint32_t code,
30 const std::string& text)
31{
Steve DiBenedetto3970c892014-01-31 23:31:13 -070032 // Path 1 - runtime exception on receive's wireDecode.
33 // Set Data response's content payload to the
34 // encoded Block.
35 {
36 ndn::ControlResponse control(code, text);
37 const Block& encodedControl = control.wireEncode();
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070038
Steve DiBenedetto3970c892014-01-31 23:31:13 -070039 NFD_LOG_DEBUG("sending control response (Path 1)"
40 << " Name: " << name
41 << " code: " << code
42 << " text: " << text);
43
44 NFD_LOG_DEBUG("sending raw control block size = " << encodedControl.size());
45
46 Data response(name);
47 response.setContent(encodedControl);
48
49 m_face->put(response);
50 }
51
52 // Path 2 - works, but not conformant to protocol.
53 // Encode ControlResponse and append Block as
54 // the last component of the name.
55 // {
56 // ndn::ControlResponse control(code, text);
57 // const Block& encodedControl = control.wireEncode();
58
59 // NFD_LOG_DEBUG("sending control response (Path 2)"
60 // << " Name: " << name
61 // << " code: " << code
62 // << " text: " << text);
63
64 // NFD_LOG_DEBUG("sending raw control block size = " << encodedControl.size());
65
66 // Name responseName(name);
67 // responseName.append(encodedControl);
68
69 // Data response(responseName);
70 // m_face->put(response);
71 // }
72
Steve DiBenedetto042bfe92014-01-30 15:05:08 -070073}
74
75
76} // namespace nfd