Browse Source

add callback_dispatcher

new_sync
Volker Birk 2 years ago
parent
commit
59e8551e17
2 changed files with 10 additions and 9 deletions
  1. +4
    -7
      server/mini-adapter-impl.cc
  2. +6
    -2
      server/mini-adapter-main.cc

+ 4
- 7
server/mini-adapter-impl.cc View File

@ -7,6 +7,7 @@
#include <pEp/status_to_string.hh> // from libpEpAdapter.
#include <pEp/locked_queue.hh>
#include <pEp/Adapter.hh>
#include <pEp/callback_dispatcher.hh>
namespace pEp {
namespace mini {
@ -35,17 +36,13 @@ namespace mini {
void startSync()
{
::pEp::Adapter::startup<dummy_t>(
&JsonAdapter::messageToSend,
&JsonAdapter::notifyHandshake,
&dummy
);
pEp::callback_dispatcher.start_sync();
}
void stopSync()
{
::pEp::Adapter::shutdown();
pEp::callback_dispatcher.stop_sync();
}
@ -54,7 +51,7 @@ void startKeyserverLookup()
if(keyserver_lookup_session)
throw std::runtime_error("KeyserverLookup already started.");
PEP_STATUS status = pEp::call_with_lock(&init, &keyserver_lookup_session, &JsonAdapter::messageToSend, &::pEp::Adapter::_inject_sync_event);
PEP_STATUS status = pEp::call_with_lock(&init, &keyserver_lookup_session, pEp::CallbackDispatcher::messageToSend, ::pEp::Adapter::_inject_sync_event);
if(status != PEP_STATUS_OK || keyserver_lookup_session==nullptr)
{
throw std::runtime_error("Cannot create keyserver lookup session! status: " + ::pEp::status_to_string(status));


+ 6
- 2
server/mini-adapter-main.cc View File

@ -16,6 +16,7 @@
#include <pEp/call_with_lock.hh>
#include <pEp/status_to_string.hh>
#include <pEp/Adapter.hh>
#include <pEp/callback_dispatcher.hh>
namespace po = boost::program_options;
@ -125,9 +126,11 @@ try
if( debug_mode == false && !foreground )
daemonize (!debug_mode, (const uintptr_t) status_handle);
pEp::callback_dispatcher.add(JsonAdapter::messageToSend, JsonAdapter::notifyHandshake);
// create a dummy session just to see whether the Engine is functional.
// reason: here we still can log errors to stderr, because prepare_run() is called before daemonize().
PEP_STATUS status = pEp::call_with_lock(&init, &first_session, &JsonAdapter::messageToSend, &pEp::Adapter::_inject_sync_event);
PEP_STATUS status = pEp::call_with_lock(&init, &first_session, pEp::CallbackDispatcher::messageToSend, pEp::Adapter::_inject_sync_event);
if(status != PEP_STATUS_OK || first_session==nullptr)
{
const std::string error_msg = "Cannot create first session! PEP_STATUS: " + ::pEp::status_to_string(status) + ".";
@ -149,7 +152,7 @@ try
try
{
ja.prepare_run(address, start_port, end_port, JsonAdapter::messageToSend);
ja.prepare_run(address, start_port, end_port, pEp::CallbackDispatcher::messageToSend);
if( debug_mode )
{
@ -172,6 +175,7 @@ try
ja.shutdown(nullptr);
ja.Log() << "Good bye. :-)";
pEp::call_with_lock(&release, first_session);
pEp::callback_dispatcher.remove(JsonAdapter::messageToSend);
}
catch(std::exception const& e)
{


Loading…
Cancel
Save