mirror of
https://github.com/ChronosX88/Influence-cjdns.git
synced 2024-11-09 17:31:01 +00:00
Changed the structure of the class Handler (in particular, rewrite the structure of createSession)
This commit is contained in:
parent
f694a32f3e
commit
3e4778b576
@ -5,7 +5,8 @@ Handler::Handler()
|
|||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
handlers = {
|
handlers = {
|
||||||
{"createSession", std::bind(&Handler::createSession, this, _1)}
|
{"createSession", std::bind(&Handler::createSession, this, _1)},
|
||||||
|
{"createSessionSuccess", std::bind(&Handler::createSessionSuccessMethod, this, _1)}
|
||||||
};
|
};
|
||||||
network = new Network();
|
network = new Network();
|
||||||
connect(network, &Network::json_received, this, &Handler::handle);
|
connect(network, &Network::json_received, this, &Handler::handle);
|
||||||
@ -21,16 +22,13 @@ void Handler::handle(QJsonObject jsonReceived)
|
|||||||
void Handler::createSession(QJsonObject jsonReceived)
|
void Handler::createSession(QJsonObject jsonReceived)
|
||||||
{
|
{
|
||||||
QJsonObject jsonSend;
|
QJsonObject jsonSend;
|
||||||
if(jsonReceived.contains("status") != true)
|
jsonSend["peerID"] = my_ipv6;
|
||||||
{
|
jsonSend["action"] = "createSessionSuccess";
|
||||||
jsonSend["peerID"] = my_ipv6;
|
QString peerReceiver = jsonReceived["peerID"].toString();
|
||||||
jsonSend["action"] = "createSession";
|
network->sendDatagram(jsonSend, peerReceiver);
|
||||||
jsonSend["status"] = true;
|
}
|
||||||
QString peerReceiver = jsonReceived["peerID"].toString();
|
|
||||||
network->sendDatagram(jsonSend, peerReceiver);
|
void Handler::createSessionSuccessMethod(QJsonObject jsonReceived)
|
||||||
}
|
{
|
||||||
else
|
emit createSessionSuccess();
|
||||||
{
|
|
||||||
emit createSessionSuccess();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ class Handler : public QObject
|
|||||||
Network *network;
|
Network *network;
|
||||||
void createSession(QJsonObject jsonReceived);
|
void createSession(QJsonObject jsonReceived);
|
||||||
std::map<QString, std::function<void(QJsonObject)>> handlers;
|
std::map<QString, std::function<void(QJsonObject)>> handlers;
|
||||||
|
void createSessionSuccessMethod(QJsonObject jsonReceived);
|
||||||
private slots:
|
private slots:
|
||||||
void handle(QJsonObject jsonReceived);
|
void handle(QJsonObject jsonReceived);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user