Eric Newberry | 94996d6 | 2015-05-07 13:48:46 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Davide Pesavento | 5923bf8 | 2018-08-09 01:55:44 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2015-2018, Arizona Board of Regents. |
Eric Newberry | 94996d6 | 2015-05-07 13:48:46 -0700 | [diff] [blame] | 4 | * |
| 5 | * This file is part of ndn-tools (Named Data Networking Essential Tools). |
| 6 | * See AUTHORS.md for complete list of ndn-tools authors and contributors. |
| 7 | * |
| 8 | * ndn-tools is free software: you can redistribute it and/or modify it under the terms |
| 9 | * of the GNU General Public License as published by the Free Software Foundation, |
| 10 | * either version 3 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 | * PURPOSE. See the GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 18 | * |
| 19 | * @author Eric Newberry <enewberry@email.arizona.edu> |
| 20 | */ |
| 21 | |
| 22 | #include "tracer.hpp" |
| 23 | |
| 24 | namespace ndn { |
| 25 | namespace ping { |
| 26 | namespace server { |
| 27 | |
| 28 | Tracer::Tracer(PingServer& pingServer, const Options& options) |
| 29 | : m_options(options) |
| 30 | { |
Davide Pesavento | 2bdda1d | 2018-08-09 19:35:49 -0400 | [diff] [blame] | 31 | if (!m_options.wantQuiet) { |
| 32 | pingServer.afterReceive.connect([this] (const Name& name) { onReceive(name); }); |
| 33 | } |
Eric Newberry | 94996d6 | 2015-05-07 13:48:46 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | void |
| 37 | Tracer::onReceive(const Name& name) |
| 38 | { |
Davide Pesavento | 5923bf8 | 2018-08-09 01:55:44 -0400 | [diff] [blame] | 39 | if (m_options.wantTimestamp) { |
| 40 | std::cout << time::toIsoString(time::system_clock::now()) << " - "; |
Eric Newberry | 94996d6 | 2015-05-07 13:48:46 -0700 | [diff] [blame] | 41 | } |
| 42 | |
Davide Pesavento | 5923bf8 | 2018-08-09 01:55:44 -0400 | [diff] [blame] | 43 | std::cout << "interest received: seq=" << name.at(-1) << std::endl; |
Eric Newberry | 94996d6 | 2015-05-07 13:48:46 -0700 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | } // namespace server |
| 47 | } // namespace ping |
Alexander Afanasyev | 1e7a7b2 | 2015-08-26 15:35:26 -0700 | [diff] [blame] | 48 | } // namespace ndn |