Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 1 | /* -*- 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 | |
| 12 | namespace nfd { |
| 13 | |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 14 | NFD_LOG_INIT("ManagerBase"); |
| 15 | |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 16 | ManagerBase::ManagerBase(shared_ptr<AppFace> face) |
| 17 | : m_face(face) |
| 18 | { |
| 19 | |
| 20 | } |
| 21 | |
| 22 | ManagerBase::~ManagerBase() |
| 23 | { |
| 24 | |
| 25 | } |
| 26 | |
| 27 | void |
| 28 | ManagerBase::sendResponse(const Name& name, |
| 29 | uint32_t code, |
| 30 | const std::string& text) |
| 31 | { |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 32 | ndn::ControlResponse control(code, text); |
| 33 | const Block& encodedControl = control.wireEncode(); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 34 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 35 | NFD_LOG_DEBUG("sending control response" |
| 36 | << " Name: " << name |
| 37 | << " code: " << code |
| 38 | << " text: " << text); |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 39 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 40 | Data response(name); |
| 41 | response.setContent(encodedControl); |
Steve DiBenedetto | 3970c89 | 2014-01-31 23:31:13 -0700 | [diff] [blame] | 42 | |
Steve DiBenedetto | 43cd037 | 2014-02-01 17:05:07 -0700 | [diff] [blame] | 43 | m_keyChain.sign(response); |
| 44 | m_face->put(response); |
Steve DiBenedetto | 042bfe9 | 2014-01-30 15:05:08 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | |
| 48 | } // namespace nfd |