blob: 9ab78224be5dfc6fc4e7dc5997ef8df82ed299d9 [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;
14 if (getStorageHandle()->readData(interest, data)) {
15 getFace()->put(data);
16 }
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;
23 getFace()->shutdown();
24}
25
26void
27ReadHandle::listen(const Name& prefix)
28{
29 getFace()->setInterestFilter(prefix,
30 bind(&ReadHandle::onInterest, this, _1, _2),
31 bind(&ReadHandle::onRegisterFailed, this, _1, _2));
32}
33
34} //namespace repo