mirror of
https://github.com/ChronosX88/Influence-cjdns.git
synced 2024-11-23 15:42:18 +00:00
The function "sendPing" and "send" is added.
This commit is contained in:
parent
9f3baba209
commit
33e436e330
@ -1,6 +1,28 @@
|
|||||||
#include "network.h"
|
#include "network.h"
|
||||||
|
|
||||||
network::network()
|
class Network
|
||||||
{
|
{
|
||||||
|
Network()
|
||||||
|
{
|
||||||
|
socket = new QUdpSocket(this);
|
||||||
|
socket->bind(QHostAddress::AnyIPv6, 6552);
|
||||||
|
connect(socket, SIGNAL(readyRead()), SLOT(read()));
|
||||||
|
}
|
||||||
|
void sendPing(QHostAddress ip)
|
||||||
|
{
|
||||||
|
json ping;
|
||||||
|
ping["action"] = "ping";
|
||||||
|
QString str = ping.dump();
|
||||||
|
send(str, ip);
|
||||||
|
}
|
||||||
|
void send(QString str, QHostAddress ip)
|
||||||
|
{
|
||||||
|
QByteArray data;
|
||||||
|
QDataStream out(&data, QIODevice::WriteOnly);
|
||||||
|
out << qint64(0);
|
||||||
|
out << str;
|
||||||
|
out.device()->seek(qint64(0));
|
||||||
|
out << qint64(data.size() - sizeof(qint64));
|
||||||
|
socket->writeDatagram(data, QHostAddress(ip), 6552);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user