blob: d9ddb014d487361b176b3e84a97f2ab6ddfdedf0 [file] [log] [blame]
Shuo Chen9c2477f2014-03-13 15:01:06 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6#include "read-handle.hpp"
7
8namespace repo {
9
10void
11ReadHandle::onInterest(const Name& prefix, const Interest& interest)
12{
13 Data data;
Shuo Chen29c77fe2014-03-18 11:29:41 -070014 if (getStorageHandle().readData(interest, data)) {
15 getFace().put(data);
Shuo Chen9c2477f2014-03-13 15:01:06 -070016 }
17}
18
19void
20ReadHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
21{
22 std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
Shuo Chen29c77fe2014-03-18 11:29:41 -070023 getFace().shutdown();
Shuo Chen9c2477f2014-03-13 15:01:06 -070024}
25
26void
27ReadHandle::listen(const Name& prefix)
28{
Shuo Chen29c77fe2014-03-18 11:29:41 -070029 getFace().setInterestFilter(prefix,
30 bind(&ReadHandle::onInterest, this, _1, _2),
31 bind(&ReadHandle::onRegisterFailed, this, _1, _2));
Shuo Chen9c2477f2014-03-13 15:01:06 -070032}
33
34} //namespace repo