blob: 3dca25062ae7a303f3002f76fbb79ef889866f2a [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,
Alexander Afanasyev750d1872012-03-12 15:33:56 -070036 bind (&AppDataFetch::onUpdate, m_fetcher, _1, _2, _3),
37 bind (&AppDataFetch::onRemove, m_fetcher, _1),
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080038 m_ccnxHandle)
Chaoyi Bian11f294f2012-03-08 14:28:06 -080039{
Chaoyi Bian11f294f2012-03-08 14:28:06 -080040}
41
42SyncAppSocket::~SyncAppSocket()
43{
Chaoyi Bian11f294f2012-03-08 14:28:06 -080044}
45
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080046bool SyncAppSocket::publish (const string &prefix, uint32_t session, const string &dataBuffer, int freshness)
Chaoyi Bian11f294f2012-03-08 14:28:06 -080047{
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080048 m_publisher.publishData (prefix, session, dataBuffer, freshness);
49 m_syncLogic.addLocalNames (prefix, session, m_publisher.getHighestSeq (prefix, session));
Chaoyi Bian11f294f2012-03-08 14:28:06 -080050}
51
Alexander Afanasyev172d2b72012-03-08 23:43:39 -080052}