register event handlers

JSON-2
Roker 2016-08-16 09:24:37 +02:00
parent b636088139
commit aec7e4a062
2 changed files with 33 additions and 1 deletions

View File

@ -427,9 +427,35 @@ struct JsonAdapter::Internal
evutil_socket_t sock = -1;
bool running = false;
ThreadPool threads;
PEP_STATUS messageToSend(const message* msg)
{
// TODO: implement event delivery to all registered listeners
return PEP_STATUS_OK;
}
PEP_STATUS showHandshake(const pEp_identity* self, const pEp_identity* partner)
{
// TODO: implement event delivery to all registered listeners
return PEP_STATUS_OK;
}
};
PEP_STATUS JsonAdapter::messageToSend(void* obj, const message* msg)
{
JsonAdapter* ja = static_cast<JsonAdapter*>(obj);
return ja->i->messageToSend(msg);
}
PEP_STATUS JsonAdapter::showHandshake(void* obj, const pEp_identity* self, const pEp_identity* partner)
{
JsonAdapter* ja = static_cast<JsonAdapter*>(obj);
return ja->i->showHandshake(self, partner);
}
JsonAdapter::JsonAdapter(const std::string& address, unsigned start_port, unsigned end_port)
: i(new Internal)
{
@ -477,6 +503,9 @@ try
session_registry.emplace( id, session);
std::cerr << "\tcreated new session for this thread: " << static_cast<void*>(session) << ".\n";
register_sync_callbacks( session, this, &messageToSend, &showHandshake );
}else{
std::cerr << "\tsession for this thread: " << static_cast<void*>(q->second) << ".\n";
}

View File

@ -1,7 +1,7 @@
#ifndef JSON_ADAPTER_HH
#define JSON_ADAPTER_HH
#include <pEp/pEpEngine.h>
#include <pEp/message.h>
#include "registry.hh"
#include "context.hh"
@ -50,6 +50,9 @@ public:
static
std::string version();
static PEP_STATUS messageToSend(void* obj, const message* msg);
static PEP_STATUS showHandshake(void* obj, const pEp_identity* self, const pEp_identity* partner);
private:
struct Internal;
Internal* i; // pimpl for stable interface.