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