update domo

This commit is contained in:
NADAL Jean-Baptiste
2019-11-14 15:15:31 +01:00
parent ab4a18f685
commit e5bd19f12d
14 changed files with 298 additions and 134 deletions

View File

@@ -23,12 +23,18 @@
*
*/
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com
/*-------------------------------- INCLUDES ---------------------------------*/
#include <event.h>
#include "domo-server.h"
#define kDocumentRoot "."
#define kPort "8081"
/*! ----------------------------------------------------------------------------
* @fn DomoServer
*
@@ -54,18 +60,23 @@ DomoServer::~DomoServer(void)
*/
bool DomoServer::setup(void)
{
if (m_broker.setup())
{
return false;
}
m_evt_loop = event_base_new();
if (m_evt_loop == NULL)
{
return false;
}
if (m_broker.setup(m_evt_loop))
{
fprintf(stderr, "Failed to setup the Nats Broker.\n");
return false;
}
m_server.setup(kDocumentRoot, kPort, m_evt_loop);
// TODO
m_broker.connect();
return true;
}
@@ -76,6 +87,11 @@ bool DomoServer::setup(void)
*/
void DomoServer::terminate(void)
{
m_broker.terminate();
if (m_evt_loop != NULL)
event_base_free(m_evt_loop);
libevent_global_shutdown();
}
/*! ----------------------------------------------------------------------------
@@ -85,5 +101,6 @@ void DomoServer::terminate(void)
*/
int DomoServer::loop(void)
{
event_base_dispatch(m_evt_loop);
return 0;
}