singleton

synchronous
Volker Birk 2020-06-30 22:41:15 +02:00
parent be0a19d37e
commit 4cee907912
2 changed files with 12 additions and 1 deletions

View File

@ -3,8 +3,16 @@
#include <cassert>
namespace pEp {
bool CallbackDispatcher::once = true;
CallbackDispatcher dispatcher;
CallbackDispatcher::CallbackDispatcher()
{
if (!once)
throw std::out_of_range("CallbackDispatcher is a singleton");
once = false;
}
PEP_STATUS CallbackDispatcher::messageToSend(::message *msg)
{
return dispatcher._messageToSend(msg);

View File

@ -9,10 +9,13 @@ namespace pEp {
::messageToSend_t messageToSend;
::notifyHandshake_t notifyHandshake;
};
std::vector<callbacks> targets;
static bool once;
public:
CallbackDispatcher();
static PEP_STATUS messageToSend(::message *msg);
static PEP_STATUS notifyHandshake(::pEp_identity *me,
::pEp_identity *partner, ::sync_handshake_signal signal);