NDEVR
API Documentation
AdaptiveWebServer.h
1#pragma once
2#include <NDEVR/NDEVRCommunicationLogic.h>
3#include <NDEVR/Buffer.h>
4#include <NDEVR/QueueBuffer.h>
5#include <NDEVR/Dictionary.h>
6#include <NDEVR/UUID.h>
7#include <NDEVR/ApplicationOption.h>
8#include <QWebSocketServer>
9#include <NDEVR/TimeSpan.h>
10#include <QElapsedTimer>
11#include <QTimer>
12namespace NDEVR
13{
17 class AdaptiveWebServer : public QObject, public NDEVRCommunicationLogic
18 {
19 Q_OBJECT
20 public:
30 explicit AdaptiveWebServer(QObject* parent = nullptr);
31 String start(quint16 port);
32 virtual uint08 rx(void* socket, NDEVRDataPacket& packet) override;
33 virtual uint08 tx(void* socket, NDEVRDataPacket& packet, uint08 size) override;
34 virtual uint08 bytesAvailable(void* socket) override;
35 virtual void updateWindowSize(NDEVRConnectionData& state) override;
36 virtual void wait(const TimeSpan& span, LogPtr log = nullptr) override;
37 void* connectTo(const NDEVRServerInfo& info) override;
38 virtual void disconnectFrom(void* socket);
39 void setSocketServer(QWebSocketServer* server);
40 virtual bool isOpen(void* socket = nullptr) const override;
41 public:
49 private slots:
50 void onBinaryMessageReceived(const QByteArray& message, bool last);
51 void onBinaryMessageSent(qint64 send_size);
52 void onSendTick();
53 void onNewConnection();
54 void onErrorOccurredSlot(QAbstractSocket::SocketError error);
55 private:
56 QTimer m_send_timer;
57 QWebSocketServer* m_server = nullptr;
58 };
59}
WebSocket server implementation of NDEVRCommunicationLogic with optional SSL/TLS support.
static ApplicationOption< String > certificate_file
Path to the SSL certificate file.
PrivateKeyAlgorithm
Supported private key algorithms for SSL.
@ e_dsa
DSA algorithm.
@ e_dh
Diffie-Hellman algorithm.
@ e_ec
Elliptic Curve algorithm.
@ e_rsa
RSA algorithm.
@ e_opaque
Opaque key type.
static ApplicationOption< PrivateKeyAlgorithm > key_algorithm
Algorithm used for the private key.
static ApplicationOption< uint02 > default_port
Default listening port.
static ApplicationOption< bool > use_ssl
Whether to enable SSL/TLS.
static ApplicationOption< String > key_file
Path to the SSL private key file.
static ApplicationOption< TimeSpan > service_time
Interval between send ticks.
static ApplicationOption< uint08 > window_size
Default transmission window size.
The default object to store data of any type that should persist through sessions of the application.
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
The core String class for the NDEVR API.
Definition String.h:95
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Holds the state of a single NDEVR network connection, including transmit and receive packets.
Contains the address, credentials, and security flag needed to connect to an NDEVR server.