NDEVR
API Documentation
WebSocketConnection.h
Go to the documentation of this file.
1#pragma once
6#include "DLLInfo.h"
7#include <NDEVR/Connection.h>
8#include "Base/Headers/TranslatedString.h"
9class QWebSocket;
10namespace NDEVR
11{
22 class NDEVR_WEB_SOCKET_API WebSocketConnection : public ConnectionBackend
23 {
24 Q_OBJECT
25 public:
30 WebSocketConnection(LogPtr log);
34 ~WebSocketConnection();
40 virtual uint04 peek(char*, uint04 size) const override;
46 virtual uint04 rx(char*, uint04 size = Constant<uint04>::Max) override;
51 virtual void tx(const StringView& command) override;
56 void txInThread(const StringView& command);
62 virtual bool open(const ConnectionInfo& request) override;
66 virtual void close() override;
71 virtual bool isOpen() const override;
76 virtual uint04 bytesAvailable() const override;
81 virtual TranslatedString lastError() const override;
87 virtual bool setPort(QWebSocket* tcp_port);
93 virtual bool waitForReadyRead(const TimeSpan& span) override;
100 virtual bool waitForConnection(QWebSocket* socket, const ConnectionInfo& request);
105 void setSocket(QWebSocket* socket);
106 protected slots:
111 void handleSocketErrorSlot(int error);
117 void binaryMessageReceived(const QByteArray& array);
123 void textMessageReceived(const QString& message);
124 protected:
125 QWebSocket* m_socket = nullptr;
126 TranslatedString m_last_error;
127 String m_data;
128 };
135 {
136 public:
142 virtual bool handlesType(const StringView& request) const override;
148 virtual ConnectionBackend* createConnection(const ConnectionInfo& request) override;
160 };
161}
Defines cross-platform DLL export/import macros for the NDEVRWebSocket module.
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides the unseen backend logic for setting up, tearing down, and sending data over a specific type...
Definition Connection.h:169
Stores factories that can be registered for creating Connections of various types by instantiating a ...
Definition Connection.h:250
The core String View class for the NDEVR API.
Definition StringView.h:58
A ConnectionBackend that allows the software to interface with QWebSocket for communicating with WebS...
virtual bool handlesType(const StringView &request) const override
Checks whether this factory handles the given connection type string.
virtual Buffer< ConnectionCategory > availableConnectionCategories() override
Returns the categories of connections this factory can provide.
virtual Buffer< ConnectionInfo > availableConnections(const ConnectionSearchParameters &params) override
Discovers and returns available WebSocket connections matching the search parameters.
virtual ConnectionBackend * createConnection(const ConnectionInfo &request) override
Creates a new WebSocketConnection backend for the given connection info.
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
A structure designed to store information about a specific Connection.
Definition Connection.h:90
Describes settings for performing a Connection search.
Definition Connection.h:149