OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
WebsocketClient.h
Go to the documentation of this file.
1#pragma once
2
3#include <QtCore/QObject>
4#include <QtWebSockets/QWebSocket>
5#include <QtNetwork/QSslError>
6
7#include <string>
8#include <list>
9
10class WebsocketClient : public QObject
11{
12 Q_OBJECT
13public:
14 WebsocketClient(const std::string& _socketUrl);
16
17 void sendMessage(const std::string& _message, std::string& _response);
18 void sendResponse(const std::string& _message);
19
21
22 void isClosing(void) { m_sessionIsClosing = true; }
23
24Q_SIGNALS:
25 void closed();
26
27private Q_SLOTS:
28 void slotConnected();
29 void slotMessageReceived(const QString& _message);
30 void slotSocketDisconnected();
31 void slotSslErrors(const QList<QSslError>& _errors);
32 void slotProcessMessageQueue(void);
33
34private:
35 void handleMessageReceived(const QString& _message, bool _isExternalMessage);
36 void processMessages(void);
37 void sendExecuteOrQueueMessage(QString message);
38 bool ensureConnection(void);
39 void queueMessageProcessingIfNeeded(void);
40 bool anyWaitingForResponse(void) const;
41
42 QWebSocket m_webSocket;
43 QUrl m_url;
44 bool m_isConnected;
45 std::map<std::string, bool> m_waitingForResponse;
46 bool m_currentlyProcessingQueuedMessage;
47 std::string m_responseText;
48 std::list<QString> m_commandQueue;
49 bool m_sessionIsClosing;
50};
51
Definition WebsocketClient.h:11
void sendMessage(const std::string &_message, std::string &_response)
Definition WebsocketClient.cpp:89
void finishedProcessingQueuedMessage(void)
Definition WebsocketClient.cpp:122
void sendResponse(const std::string &_message)
Definition WebsocketClient.cpp:114
void isClosing(void)
Definition WebsocketClient.h:22
~WebsocketClient()
Definition WebsocketClient.cpp:82
WebsocketClient(const std::string &_socketUrl)
Definition WebsocketClient.cpp:26