From cc6c627058e779afdafba5c3624a5477d3b97a71 Mon Sep 17 00:00:00 2001 From: Hatef Date: Wed, 29 Jun 2022 13:19:04 +0430 Subject: [PATCH] .ignore Update Auto saves --- .gitignore | 2 ++ socket.cpp.autosave | 50 --------------------------------------------- socket.h.autosave | 30 --------------------------- 3 files changed, 2 insertions(+), 80 deletions(-) delete mode 100644 socket.cpp.autosave delete mode 100644 socket.h.autosave diff --git a/.gitignore b/.gitignore index 178750e..e8bb769 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.pro.user +*.autosave +*.txt Tesp_Script.cpp diff --git a/socket.cpp.autosave b/socket.cpp.autosave deleted file mode 100644 index 2bbaf1b..0000000 --- a/socket.cpp.autosave +++ /dev/null @@ -1,50 +0,0 @@ -#include "socket.h" -#include - -UdpSocket::UdpSocket(QObject* parent, quint16 port) : - QObject(parent), - _port(port) -{ - _socket = new QUdpSocket(this); - _socket->bind(QHostAddress::LocalHost, port); - connect(_socket, &QUdpSocket::readyRead, this, &UdpSocket::readyRead); -} - -UdpSocket::~UdpSocket() -{ - delete _socket; -} - -void UdpSocket::sayHello() -{ - sayMsg("Connected :))"); -} - -void UdpSocket::sayMsg(QString Msg) -{ - QByteArray Data; - Data.append(Msg); - _socket->writeDatagram(Data, QHostAddress::LocalHost, _port); -} - -QString UdpSocket::getTime() -{ - QDateTime current_time_object = QDateTime::currentDateTime(); - QString formatted_time = current_time_object.toString("yyyy/MM/dd - hh:mm:ss"); - - return formatted_time; -} - -void UdpSocket::readyRead() -{ - QByteArray Buffer; - Buffer.resize(_socket->pendingDatagramSize()); - QHostAddress sender_addr; - quint16 sender_port; - _socket->readDatagram(Buffer.data(), Buffer.size(), &sender_addr, &sender_port); - - qDebug() << "New Message arrived at" << getTime(); - qDebug() << "Address :" << sender_addr.toString(); - qDebug() << "Port : " << sender_port; - qDebug() << "Content : " << Buffer << '\n'; -} diff --git a/socket.h.autosave b/socket.h.autosave deleted file mode 100644 index 51ea612..0000000 --- a/socket.h.autosave +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef UDPSOCKET_H -#define UDPSOCKET_H - -#include -#include - -class UdpSocket : public QObject -{ - Q_OBJECT - -private: - QUdpSocket* _socket; - const quint16 _port; - - QString getTime(); - -public: - explicit UdpSocket(QObject* parent = nullptr, quint16 port = 1234); - ~UdpSocket(); - - void sayHello(); - void sayMsg(QString Msg); - - //uncrustify off -public slots: - //uncrustify on - void readyRead(); -}; - -#endif //UDPSOCKET_H