Implemented basic listening functionality
This commit is contained in:
1 parent
a62aa7ec5a
commit
00f31676dc
6 files changed
+152
-5
No files matched your search
@@ -0,0 +1,42 @@
|
||||
#include "client.h"
|
||||
|
||||
#include <QTcpSocket>
|
||||
#include <QDebug>
|
||||
|
||||
#include "server.h"
|
||||
|
||||
Client::Client(QTcpSocket *socket, Server *server) :
|
||||
QObject(server), m_socket(socket)
|
||||
{
|
||||
qDebug() << this << "connected";
|
||||
|
||||
m_socket->setParent(this);
|
||||
|
||||
connect(m_socket, &QIODevice::readyRead, this, &Client::readyRead);
|
||||
connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);
|
||||
}
|
||||
|
||||
Client::~Client()
|
||||
{
|
||||
qDebug() << this << "disconnected";
|
||||
}
|
||||
|
||||
qint64 Client::write(const char *data, qint64 len)
|
||||
{
|
||||
return m_socket->write(data, len);
|
||||
}
|
||||
|
||||
qint64 Client::write(const char *data)
|
||||
{
|
||||
return m_socket->write(data);
|
||||
}
|
||||
|
||||
qint64 Client::write(const QByteArray &data)
|
||||
{
|
||||
return m_socket->write(data);
|
||||
}
|
||||
|
||||
void Client::readyRead()
|
||||
{
|
||||
qDebug() << this << "readyRead" << m_socket->readAll();
|
||||
}
|
||||
Reference in new issue
Block a user