API Documentation
Loading...
Searching...
No Matches
TcpServer.h
Go to the documentation of this file.
1#include "DLLInfo.h"
4#include <QObject>
5
6class QTcpSocket;
7class QTcpServer;
8namespace NDEVR
9{
10 class String;
11 class File;
12 class Exception;
14 {
15 public:
16 Q_OBJECT
17 public:
18 explicit TcpServer(const String& server_name, uint04 port, QObject* parent = 0);
19 explicit TcpServer(const String& server_name, QObject* parent = 0);
20 void connectToRemoteServer(const String& remote_address);
21 void connectToRemoteServer(QTcpSocket* remote_socket);
22 protected:
23 virtual bool dataRecieved(const String& data_type, const String& args, const String& data, QTcpSocket* socket);
24 virtual bool fileRecieved(const String& data_type, const String& args, const File& data, QTcpSocket* socket);
25 public:
26 static QByteArray CreateMessagePacket(const String& type, const String& data, const String& args = String());
27 static QByteArray CreateFilePacket(const File& file, bool send_file_contents);
28 static QByteArray CreateOpenAppPacket(const File& application, const String& args = String(), bool wait_for_completion = true, bool windowless = false);
29 static QByteArray CreateOpenFilePacket(const File& file_to_open);
30 static QByteArray CreatRequestSendFilePacket(const File& file_to_request, const String& args = String());
31 static QByteArray CreateSendErrorPacket(const Exception& e);
32 public:
33 virtual bool sendData(const String& data, QTcpSocket* socket = nullptr);
34 virtual bool sendFile(const File& file, QTcpSocket* socket = nullptr);
35 virtual bool sendFile(const File& file, bool send_file_contents, QTcpSocket* socket = nullptr);
36 virtual bool sendShowFileBrowser(QTcpSocket* socket = nullptr);
37 virtual bool sendSetScreenResolution(const Vector<2, uint04>& size, QTcpSocket* socket = nullptr);
38 virtual bool sendOpenApp(const File& application, const String& args, bool wait_for_completion, bool windowless, QTcpSocket* socket = nullptr);
39 virtual bool sendData(const String& data_type, const String& data, QTcpSocket* socket = nullptr);
40 virtual bool sendError(const Exception& e, QTcpSocket* socket = nullptr);
41 virtual bool sendPacket(const QByteArray& packet, QTcpSocket* socket = nullptr);
42 protected:
43 virtual void socketDisconnected(QTcpSocket* socket);
44 virtual void showError(const Exception& e);
45
46 public slots:
47 void newConnectionSlot();
48 void readSocketSlot();
49 void discardSocketSlot();
50 void displayErrorSlot(int socketError);
51 public:
52 static constexpr const char* generic_data_message_type = "data";
53 static constexpr const char* error_data_message = "send_error_message";
54 static constexpr const char* open_os_settings = "open_os_settings";
55 static constexpr const char* set_screen_resolution = "set_screen_resolution";
56 static constexpr const char* generic_file_message_type = "file";
57 static constexpr const char* start_application_file_message_type = "start_application";
58 static constexpr const char* open_file_message_type = "open_file";
59 static constexpr const char* request_send_file = "request_send_file";
60 private:
61 QTcpServer* server;
62 String m_server_name;
63 Buffer<QTcpSocket*> m_sockets;
64 };
65}
#define NDEVR_NETWORK_PROTOCOLS_API
Definition DLLInfo.h:73
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:64
Definition Exception.hpp:56
Definition File.h:47
Definition String.h:40
Definition TcpServer.h:14
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition ACIColor.h:37
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120