Cleaning the source

I start everything from scratch
This commit is contained in:
Denis Davydov 2018-06-15 15:40:33 +03:00
parent dc74275526
commit 3ee53de11a
9 changed files with 0 additions and 107 deletions

View File

@ -1,25 +0,0 @@
QT -= gui
QT += network
CONFIG += c++11 console
CONFIG -= app_bundle
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
network.cpp \
contactmanager.cpp
HEADERS += \
network.h \
contactmanager.h

View File

@ -1,10 +0,0 @@
#include "contactmanager.h"
ContactManager::sendPing(QHostAddress ip)
{
json ping;
ping["peerID"] = QHostAddress::AnyIPv6;
ping["action"] = "ping";
QString str = ping.dump();
Network::send(str, ip);
}

View File

@ -1,12 +0,0 @@
#ifndef CONTACTMANAGER_H
#define CONTACTMANAGER_H
#include "network.hpp"
class ContactManager
{
private:
sendPing(QHostAddress ip);
};
#endif // CONTACTMANAGER_H

View File

@ -1,7 +0,0 @@
#ifndef JSON_HPP
#define JSON_HPP
#include "lib/json/json.hpp"
using json = nlohmann::json;
#endif

View File

@ -1,3 +0,0 @@
#include "json.cpp"
#include "contactmanager.cpp"
#include "network.cpp"

View File

@ -1,30 +0,0 @@
#include "network.h"
class Network
{
Network()
{
socket = new QUdpSocket(this);
socket->bind(QHostAddress::AnyIPv6, 6552);
connect(socket, SIGNAL(readyRead()), SLOT(read()));
}
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);
}
void read()
{
QByteArray buffer;
buffer.resize(socket->pendingDatagramSize());
socket->readDatagram(buffer.data(), buffer.size(),
&sender;, &senderPort;);
qDebug() << "Message from: " << sender.toString();
qDebug() << "Message: " << buffer;
}
}

View File

@ -1,16 +0,0 @@
#ifndef NETWORK_HPP
#define NETWORK_HPP
#include "lib/json/json.hpp"
#include <QUdpSocket>
using json = nlohmann::json;
class network
{
public:
send(QString str, QHostAddress ip);
private:
read();
};
#endif // NETWORK_H

View File

@ -1 +0,0 @@
#include <sql.h>

View File

@ -1,3 +0,0 @@
#include <QSqlDatabase>
#include <QSqlQuery>