Commit 093d17a0 authored by fred's avatar fred
Browse files

zerogw payload api refactoring

parent 269080e7
......@@ -21,7 +21,7 @@
#include "service.h"
ZerogwProxy::ZerogwProxy(params a_ncs_params, QObject *parent) : m_ncs_params(a_ncs_params), QObject(parent)
ZerogwProxy::ZerogwProxy(params a_ncs_params, QString port, QObject *parent) : m_ncs_params(a_ncs_params), m_port(port), QObject(parent)
{
thread = new QThread;
......@@ -49,13 +49,17 @@ void ZerogwProxy::init()
qDebug() << "ZerogwProxy::init";
zerogw = new zmq::socket_t(*zeromq_->m_context, ZMQ_ROUTER);
zerogw->bind ("tcp://*:2503");
QString zgw_uri = "tcp://*:" + m_port;
//zerogw->bind ("tcp://*:2503");
zerogw->bind (zgw_uri.toLatin1());
worker_payload = new zmq::socket_t(*zeromq_->m_context, ZMQ_DEALER);
//QString uri = "ipc://" + m_ncs_params.base_directory + "/payloads";
QString uri = "ipc://" + m_ncs_params.base_directory + "/payloads";
worker_payload->bind (uri.toLatin1());
api_payload = new Api_payload(m_ncs_params.base_directory, 0);
api_payload2 = new Api_payload(m_ncs_params.base_directory, 0);
api_payload2 = new Api_payload(m_ncs_params.base_directory, 1);
qDebug() << "ZerogwProxy::init BEFORE PROXY";
zmq::proxy (*zerogw, *worker_payload, NULL);
......@@ -72,6 +76,7 @@ Service::Service(params a_ncs_params, QObject *parent) : m_ncs_params(a_ncs_para
m_xmpp_server = NULL;
m_xmpp_client = NULL;
zerogwToPayload = NULL;
zerogwToPayload2 = NULL;
}
......@@ -101,6 +106,8 @@ Service::~Service()
delete(worker_api);
//delete(api_payload);
if (zerogwToPayload) delete(zerogwToPayload);
if (zerogwToPayload2) delete(zerogwToPayload2);
delete(api_node);
delete(api_workflow);
delete(api_user);
......@@ -131,7 +138,9 @@ void Service::Http_api_init()
m_ncs_params.api_port == 0 ? port = 2502 : port = m_ncs_params.api_port;
zerogwToPayload = new ZerogwProxy(m_ncs_params);
zerogwToPayload = new ZerogwProxy(m_ncs_params, "2403");
zerogwToPayload2 = new ZerogwProxy(m_ncs_params, "2404");
/*
zmq::socket_t zerogw (*zeromq_->m_context, ZMQ_ROUTER);
......
......@@ -41,13 +41,14 @@ class ZerogwProxy : public QObject
{
Q_OBJECT
public:
ZerogwProxy(params a_ncs_params, QObject *parent = 0);
ZerogwProxy(params a_ncs_params, QString port, QObject *parent = 0);
~ZerogwProxy();
private slots:
void init();
private:
QString m_port;
QThread *thread;
Zeromq *zeromq_;
zmq::socket_t *zerogw;
......@@ -74,6 +75,8 @@ public:
void link();
Worker_api *worker_api;
ZerogwProxy *zerogwToPayload;
ZerogwProxy *zerogwToPayload2;
Api_node *api_node;
Api_workflow *api_workflow;
Api_user *api_user;
......
......@@ -63,7 +63,7 @@ void Zerogw::init()
m_socket_zerogw->setsockopt(ZMQ_SNDHWM, &hwm, sizeof (hwm));
m_socket_zerogw->setsockopt(ZMQ_RCVHWM, &hwm, sizeof (hwm));
if (m_port == 0 )
if (m_port == 0 || m_port == 1)
{
// QString uri = "tcp://127.0.0.1:2504" + QString::number(port);
QString uri = "ipc://" + m_basedirectory + "/payloads";
......@@ -227,7 +227,7 @@ void Api_payload::receive_http_payload()
{
check_http_data->setEnabled(false);
std::cout << "Api_payload::receive_payload" << std::endl;
std::cout << "Api_payload::receive_payload : API : " << m_port << std::endl;
QHash <QString, QString> zerogw;
QString key;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment