25 const ndn::security::SigningInfo& signingInfo,
size_t imsLimit)
27 , m_scheduler(m_face.getIoContext())
28 , m_segmenter(keyChain, signingInfo)
35 ndn::span<const uint8_t> buffer, ndn::time::milliseconds freshness)
37 auto segments = m_segmenter.segment(buffer, ndn::Name(dataName).appendVersion(),
38 ndn::MAX_NDN_PACKET_SIZE >> 1, freshness);
39 for (
const auto& data : segments) {
40 m_ims.insert(*data, freshness);
41 m_scheduler.schedule(freshness, [
this, name = data->getName()] { m_ims.erase(name); });
46 uint64_t interestSegment = 0;
47 if (interestName[-1].isSegment()) {
48 interestSegment = interestName[-1].toSegment();
50 if (interestSegment < segments.size()) {
51 m_face.put(*segments[interestSegment]);
58 auto it = m_ims.find(interestName);
bool replyFromStore(const ndn::Name &interestName)
Try to reply from memory, return false if we cannot find the segment.
SegmentPublisher(ndn::Face &face, ndn::KeyChain &keyChain, const ndn::security::SigningInfo &signingInfo=ndn::security::SigningInfo(), size_t imsLimit=100)
void publish(const ndn::Name &interestName, const ndn::Name &dataName, ndn::span< const uint8_t > buffer, ndn::time::milliseconds freshness)
Put all the segments in memory.