summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/echoclient/echoclient.cpp10
-rw-r--r--examples/echoclient/echoclient.h10
-rw-r--r--examples/echoclient/echoclient.pro6
-rw-r--r--examples/echoclient/main.cpp5
-rw-r--r--examples/examples.pro2
5 files changed, 16 insertions, 17 deletions
diff --git a/examples/echoclient/echoclient.cpp b/examples/echoclient/echoclient.cpp
index 0bbfa0f..d469867 100644
--- a/examples/echoclient/echoclient.cpp
+++ b/examples/echoclient/echoclient.cpp
@@ -1,22 +1,22 @@
-#include "websocketclient.h"
+#include "echoclient.h"
#include <QDebug>
-WebSocketClient::WebSocketClient(QObject *parent) :
+EchoClient::EchoClient(const QUrl &url, QObject *parent) :
QObject(parent),
m_webSocket()
{
connect(&m_webSocket, SIGNAL(connected()), this, SLOT(onConnected()));
- m_webSocket.open(QUrl("ws://localhost:1234"));
+ m_webSocket.open(QUrl(url));
}
-void WebSocketClient::onConnected()
+void EchoClient::onConnected()
{
qDebug() << "Websocket connected";
connect(&m_webSocket, SIGNAL(textMessageReceived(QString)), this, SLOT(onTextMessageReceived(QString)));
m_webSocket.send("Hello, world!");
}
-void WebSocketClient::onTextMessageReceived(QString message)
+void EchoClient::onTextMessageReceived(QString message)
{
qDebug() << "Message received:" << message;
}
diff --git a/examples/echoclient/echoclient.h b/examples/echoclient/echoclient.h
index 33458c8..4405071 100644
--- a/examples/echoclient/echoclient.h
+++ b/examples/echoclient/echoclient.h
@@ -1,14 +1,14 @@
-#ifndef WEBSOCKETCLIENT_H
-#define WEBSOCKETCLIENT_H
+#ifndef ECHOCLIENT_H
+#define ECHOCLIENT_H
#include <QObject>
#include "websocket.h"
-class WebSocketClient : public QObject
+class EchoClient : public QObject
{
Q_OBJECT
public:
- explicit WebSocketClient(QObject *parent = 0);
+ explicit EchoClient(const QUrl &url, QObject *parent = 0);
Q_SIGNALS:
@@ -22,4 +22,4 @@ private:
WebSocket m_webSocket;
};
-#endif // WEBSOCKETCLIENT_H
+#endif // ECHOCLIENT_H
diff --git a/examples/echoclient/echoclient.pro b/examples/echoclient/echoclient.pro
index 4004717..6e3623c 100644
--- a/examples/echoclient/echoclient.pro
+++ b/examples/echoclient/echoclient.pro
@@ -1,7 +1,7 @@
QT += core
QT -= gui
-TARGET = websocketclient
+TARGET = echoclient
CONFIG += console
CONFIG -= app_bundle
@@ -10,7 +10,7 @@ TEMPLATE = app
include(../../source/websocket.pri)
SOURCES += main.cpp \
- websocketclient.cpp
+ echoclient.cpp
HEADERS += \
- websocketclient.h
+ echoclient.h
diff --git a/examples/echoclient/main.cpp b/examples/echoclient/main.cpp
index 9a57b9b..4a94284 100644
--- a/examples/echoclient/main.cpp
+++ b/examples/echoclient/main.cpp
@@ -1,11 +1,10 @@
#include <QCoreApplication>
-#include "websocketclient.h"
+#include "echoclient.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
-
- WebSocketClient client;
+ EchoClient client(QUrl("ws://localhost:1234"));
Q_UNUSED(client);
diff --git a/examples/examples.pro b/examples/examples.pro
index a3bca2a..bb960a8 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,4 +1,4 @@
TEMPLATE = subdirs
-SUBDIRS = websocketclient \
+SUBDIRS = echoclient \
echoserver