blob: d703e76cbdd07031b7b679842d4ae4d369c89f31 [file] [log] [blame]
Zhenkai Zhubed78952012-03-06 11:06:08 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2012 University of California, Los Angeles
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
19 * 卞超轶 Chaoyi Bian <bcy@pku.edu.cn>
20 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
21 */
Chaoyi Bian11f294f2012-03-08 14:28:06 -080022
23#include "sync-app-socket.h"
24
25using namespace std;
26using namespace boost;
27
28namespace Sync
29{
30
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080031SyncAppSocket::SyncAppSocket (const string &syncPrefix, CcnxWrapper::DataCallback dataCallback)
32 : m_ccnxHandle (new CcnxWrapper())
33 , m_fetcher (m_ccnxHandle, dataCallback)
34 , m_publisher (m_ccnxHandle)
35 , m_syncLogic (syncPrefix,
36 bind (&AppDataFetch::fetch, m_fetcher, _1, _2, _3),
37 m_ccnxHandle)
Chaoyi Bian11f294f2012-03-08 14:28:06 -080038{
Chaoyi Bian11f294f2012-03-08 14:28:06 -080039}
40
41SyncAppSocket::~SyncAppSocket()
42{
Chaoyi Bian11f294f2012-03-08 14:28:06 -080043}
44
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080045bool SyncAppSocket::publish (const string &prefix, uint32_t session, const string &dataBuffer, int freshness)
Chaoyi Bian11f294f2012-03-08 14:28:06 -080046{
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080047 m_publisher.publishData (prefix, session, dataBuffer, freshness);
48 m_syncLogic.addLocalNames (prefix, session, m_publisher.getHighestSeq (prefix, session));
Chaoyi Bian11f294f2012-03-08 14:28:06 -080049}
50
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080051}