diff options
author | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-08-12 11:00:58 +0200 |
---|---|---|
committer | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-08-12 11:00:58 +0200 |
commit | ea0800163c8c994f50211ce4f76d157f84ac73ef (patch) | |
tree | 4e709f8e97ed8d63d5a96aca22103561b4f36a82 | |
parent | 2b193c459f0d62a7b81b79182589cf4d39e3b667 (diff) | |
download | qtwebsockets-ea0800163c8c994f50211ce4f76d157f84ac73ef.tar.gz |
Renamed HelloWorldServer to EchoServer
-rw-r--r-- | examples/echoserver/echoserver.cpp (renamed from examples/websocketserver/helloworldserver.cpp) | 16 | ||||
-rw-r--r-- | examples/echoserver/echoserver.h (renamed from examples/websocketserver/helloworldserver.h) | 10 | ||||
-rw-r--r-- | examples/echoserver/echoserver.pro | 16 | ||||
-rw-r--r-- | examples/echoserver/main.cpp (renamed from examples/websocketserver/main.cpp) | 4 | ||||
-rw-r--r-- | examples/examples.pro | 2 | ||||
-rw-r--r-- | examples/websocketserver/websocketserver.pro | 23 |
6 files changed, 31 insertions, 40 deletions
diff --git a/examples/websocketserver/helloworldserver.cpp b/examples/echoserver/echoserver.cpp index efcd5b9..4f5a80d 100644 --- a/examples/websocketserver/helloworldserver.cpp +++ b/examples/echoserver/echoserver.cpp @@ -1,9 +1,9 @@ -#include "helloworldserver.h" +#include "echoserver.h" #include "websocketserver.h" #include "websocket.h" #include <QDebug> -HelloWorldServer::HelloWorldServer(quint16 port, QObject *parent) : +EchoServer::EchoServer(quint16 port, QObject *parent) : QObject(parent), m_pWebSocketServer(0), m_clients() @@ -11,14 +11,13 @@ HelloWorldServer::HelloWorldServer(quint16 port, QObject *parent) : m_pWebSocketServer = new WebSocketServer(this); if (m_pWebSocketServer->listen(QHostAddress::Any, port)) { - qDebug() << "HelloWorld Server listening on port" << port; + qDebug() << "Echoserver listening on port" << port; connect(m_pWebSocketServer, SIGNAL(newConnection()), this, SLOT(onNewConnection())); } } -void HelloWorldServer::onNewConnection() +void EchoServer::onNewConnection() { - //qDebug() << "Client connected."; WebSocket *pSocket = m_pWebSocketServer->nextPendingConnection(); connect(pSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(processMessage(QString))); @@ -29,7 +28,7 @@ void HelloWorldServer::onNewConnection() m_clients << pSocket; } -void HelloWorldServer::processMessage(QString message) +void EchoServer::processMessage(QString message) { WebSocket *pClient = qobject_cast<WebSocket *>(sender()); if (pClient != 0) @@ -38,7 +37,7 @@ void HelloWorldServer::processMessage(QString message) } } -void HelloWorldServer::processBinaryMessage(QByteArray message) +void EchoServer::processBinaryMessage(QByteArray message) { WebSocket *pClient = qobject_cast<WebSocket *>(sender()); if (pClient != 0) @@ -47,12 +46,11 @@ void HelloWorldServer::processBinaryMessage(QByteArray message) } } -void HelloWorldServer::socketDisconnected() +void EchoServer::socketDisconnected() { WebSocket *pClient = qobject_cast<WebSocket *>(sender()); if (pClient != 0) { - //qDebug() << "Client disconnected"; m_clients.removeAll(pClient); pClient->deleteLater(); } diff --git a/examples/websocketserver/helloworldserver.h b/examples/echoserver/echoserver.h index 156597d..21cf0de 100644 --- a/examples/websocketserver/helloworldserver.h +++ b/examples/echoserver/echoserver.h @@ -1,5 +1,5 @@ -#ifndef HELLOWORLDSERVER_H -#define HELLOWORLDSERVER_H +#ifndef ECHOSERVER_H +#define ECHOSERVER_H #include <QObject> #include <QList> @@ -8,11 +8,11 @@ class WebSocketServer; class WebSocket; -class HelloWorldServer : public QObject +class EchoServer : public QObject { Q_OBJECT public: - explicit HelloWorldServer(quint16 port, QObject *parent = 0); + explicit EchoServer(quint16 port, QObject *parent = 0); Q_SIGNALS: @@ -27,4 +27,4 @@ private: QList<WebSocket *> m_clients; }; -#endif // HELLOWORLDSERVER_H +#endif //ECHOSERVER_H diff --git a/examples/echoserver/echoserver.pro b/examples/echoserver/echoserver.pro new file mode 100644 index 0000000..2cb13e1 --- /dev/null +++ b/examples/echoserver/echoserver.pro @@ -0,0 +1,16 @@ +QT += core +QT -= gui + +TARGET = echoserver +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +include(../../source/websocket.pri) + +SOURCES += main.cpp \ + echoserver.cpp + +HEADERS += \ + echoserver.h diff --git a/examples/websocketserver/main.cpp b/examples/echoserver/main.cpp index d5060ae..390cbb0 100644 --- a/examples/websocketserver/main.cpp +++ b/examples/echoserver/main.cpp @@ -1,10 +1,10 @@ #include <QCoreApplication> -#include "helloworldserver.h" +#include "echoserver.h" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); - HelloWorldServer server(1234); + EchoServer server(1234); Q_UNUSED(server); diff --git a/examples/examples.pro b/examples/examples.pro index 9f9fe6e..a3bca2a 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,4 +1,4 @@ TEMPLATE = subdirs SUBDIRS = websocketclient \ - websocketserver + echoserver diff --git a/examples/websocketserver/websocketserver.pro b/examples/websocketserver/websocketserver.pro deleted file mode 100644 index 599945c..0000000 --- a/examples/websocketserver/websocketserver.pro +++ /dev/null @@ -1,23 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2013-08-03T19:54:35 -# -#------------------------------------------------- - -QT += core - -QT -= gui - -TARGET = websocketserver -CONFIG += console -CONFIG -= app_bundle - -TEMPLATE = app - -include(../../source/websocket.pri) - -SOURCES += main.cpp \ - helloworldserver.cpp - -HEADERS += \ - helloworldserver.h |