basicly complete sync-ccnx-wrapper.cc
diff --git a/model/sync-ccnx-wrapper.cc b/model/sync-ccnx-wrapper.cc
index 9a2e3bb..a7936a3 100644
--- a/model/sync-ccnx-wrapper.cc
+++ b/model/sync-ccnx-wrapper.cc
@@ -22,7 +22,6 @@
#include "sync-ccnx-wrapper.h"
#include <poll.h>
-#include <ccn/signing.h>
using namespace std;
using namespace boost;
@@ -35,7 +34,7 @@
ccn_connect(m_handle, NULL);
initKeyStore();
createKeyLocator();
- m_thread = thread(&CcnxWrapper::ccnLoop);
+ m_thread = thread(&CcnxWrapper::ccnLoop, this);
}
CcnxWrapper::~CcnxWrapper()
@@ -140,7 +139,7 @@
ccn_upcall_kind kind,
ccn_upcall_info *info)
{
- function< void (string) > callback = selfp->data;
+ function<void (string)> f = *(function<void (string)> *)selfp->data;
switch (kind)
{
@@ -158,7 +157,7 @@
char *comp;
size_t size;
ccn_name_comp_get(info->content_ccnb, info->content_comps, info->content_comps->n - 3, (const unsigned char **)&comp, &size);
- callback(string(comp));
+ f((string)comp);
}
static ccn_upcall_res incomingData(
@@ -166,7 +165,7 @@
ccn_upcall_kind kind,
ccn_upcall_info *info)
{
- function< void (string) > callback = selfp->data;
+ function<void (shared_ptr<DataBuffer>)> f = *(function<void (shared_ptr<DataBuffer>)> *)selfp->data;
switch (kind)
{
@@ -184,29 +183,32 @@
char *pcontent;
size_t len;
ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E], info->pco, (const unsigned char **)&pcontent, &len);
- callback(string(pcontent));
+ shared_ptr<DataBuffer> data(new DataBufferImpl((const unsigned char*)pcontent, len));
+ f(data);
}
-int CcnxWrapper::sendInterest(string strInterest, boost::function< void (shared_ptr< DataBuffer >) > dataCallback)
+int CcnxWrapper::sendInterest(string strInterest, function< void (shared_ptr< DataBuffer >) > dataCallback)
{
ccn_charbuf *pname = ccn_charbuf_create();
ccn_closure *dataClosure = new ccn_closure;
+ function<void (shared_ptr< DataBuffer >)> *f = new function<void (shared_ptr< DataBuffer >)>(dataCallback);
ccn_name_from_uri(pname, strInterest.c_str());
ccn_express_interest(m_handle, pname, dataClosure, NULL);
- dataClosure->data = dataCallback.target<void (shared_ptr< DataBuffer >)>();
+ dataClosure->data = f;
dataClosure->p = &incomingData;
ccn_charbuf_destroy(&pname);
}
-int CcnxWrapper::setInterestFilter(string prefix, boost::function< void (string) > interestCallback)
+int CcnxWrapper::setInterestFilter(string prefix, function< void (string) > interestCallback)
{
ccn_charbuf *pname = ccn_charbuf_create();
ccn_closure *interestClosure = new ccn_closure;
+ function<void (string)> *f = new function<void (string)>(interestCallback);
ccn_name_from_uri(pname, prefix.c_str());
- interestClosure->data = interestCallback.target<void (string)>();
+ interestClosure->data = f;
interestClosure->p = &incomingInterest;
ccn_set_interest_filter(m_handle, pname, interestClosure);