blob: 9ab78224be5dfc6fc4e7dc5997ef8df82ed299d9 [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (C) 2014 Regents of the University of California.
* See COPYING for copyright and distribution information.
*/
#include "read-handle.hpp"
namespace repo {
void
ReadHandle::onInterest(const Name& prefix, const Interest& interest)
{
Data data;
if (getStorageHandle()->readData(interest, data)) {
getFace()->put(data);
}
}
void
ReadHandle::onRegisterFailed(const Name& prefix, const std::string& reason)
{
std::cerr << "ERROR: Failed to register prefix in local hub's daemon" << std::endl;
getFace()->shutdown();
}
void
ReadHandle::listen(const Name& prefix)
{
getFace()->setInterestFilter(prefix,
bind(&ReadHandle::onInterest, this, _1, _2),
bind(&ReadHandle::onRegisterFailed, this, _1, _2));
}
} //namespace repo