bigsnitch/proxyhandler.cpp
Tim Blume 600d7146d3 foo
2021-03-20 22:56:03 +01:00

27 lines
801 B
C++

#include "proxyhandler.h"
#include <QThread>
bool http::ProxyHandler::loadPlugin(QObject *proxy)
{
auto inst = qobject_cast<ProxyInterface*>(proxy);
if(!inst) {
return false;
}
qDebug("loading proxy");
auto thread = new QThread;
proxy->moveToThread(thread);
// TODO: get path from config or something
inst->path = "tcp://127.0.0.1:12345";
QObject::connect(thread, SIGNAL (started()), proxy, SLOT (process()));
QObject::connect(proxy, SIGNAL (error(QString)), this, SIGNAL (error(QString)), Qt::QueuedConnection);
QObject::connect(proxy, SIGNAL (message(http::Flow)), this, SIGNAL (message(http::Flow)), Qt::QueuedConnection);
thread->start();
auto name = inst->getName();
proxies.insert({name, {inst, thread}});
return true;
}