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;
13 /**--------------------------------------------------------------------------------------------------
14 \brief A TcpServer allows the software to recieve socket connections from external sources.
15 **/
17 {
18 public:
19 Q_OBJECT
20 public:
21 explicit TcpServer(const String& server_name, uint04 port, QObject* parent = 0);
22 explicit TcpServer(const String& server_name, QObject* parent = 0);
23 void connectToRemoteServer(const String& remote_address);
24 void connectToRemoteServer(QTcpSocket* remote_socket);
25 protected:
26 virtual bool dataRecieved(const String& data_type, const String& args, const String& data, QTcpSocket* socket);
27 virtual bool fileRecieved(const String& data_type, const String& args, const File& data, QTcpSocket* socket);
28 public:
29 static QByteArray CreateMessagePacket(const String& type, const String& data, const String& args = String());
30 static QByteArray CreateFilePacket(const File& file, bool send_file_contents);
31 static QByteArray CreateOpenAppPacket(const File& application, const String& args = String(), bool wait_for_completion = true, bool windowless = false);
32 static QByteArray CreateOpenFilePacket(const File& file_to_open);
33 static QByteArray CreatRequestSendFilePacket(const File& file_to_request, const String& args = String());
34 static QByteArray CreateSendErrorPacket(const Exception& e);
35 public:
36 virtual bool sendData(const String& data, QTcpSocket* socket = nullptr);
37 virtual bool sendFile(const File& file, QTcpSocket* socket = nullptr);
38 virtual bool sendFile(const File& file, bool send_file_contents, QTcpSocket* socket = nullptr);
39 virtual bool sendShowFileBrowser(QTcpSocket* socket = nullptr);
40 virtual bool sendSetScreenResolution(const Vector<2, uint04>& size, QTcpSocket* socket = nullptr);
41 virtual bool sendOpenApp(const File& application, const String& args, bool wait_for_completion, bool windowless, QTcpSocket* socket = nullptr);
42 virtual bool sendData(const String& data_type, const String& data, QTcpSocket* socket = nullptr);
43 virtual bool sendError(const Exception& e, QTcpSocket* socket = nullptr);
44 virtual bool sendPacket(const QByteArray& packet, QTcpSocket* socket = nullptr);
45 protected:
46 virtual void socketDisconnected(QTcpSocket* socket);
47 virtual void showError(const Exception& e);
48
49 public slots:
53 void displayErrorSlot(int socketError);
54 public:
55 static constexpr const char* generic_data_message_type = "data";
56 static constexpr const char* error_data_message = "send_error_message";
57 static constexpr const char* open_os_settings = "open_os_settings";
58 static constexpr const char* set_screen_resolution = "set_screen_resolution";
59 static constexpr const char* generic_file_message_type = "file";
60 static constexpr const char* start_application_file_message_type = "start_application";
61 static constexpr const char* open_file_message_type = "open_file";
62 static constexpr const char* request_send_file = "request_send_file";
63 private:
64 QTcpServer* server;
65 String m_server_name;
66 Buffer<QTcpSocket*> m_sockets;
67 };
68}
#define NDEVR_NETWORK_PROTOCOLS_API
Definition DLLInfo.h:55
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides consistent interface to handle errors through the throw expression. All exceptions generated...
Definition Exception.hpp:47
Logic for reading or writing to a file as well as navigating filesystems.
Definition File.h:48
The core String class for the NDEVR API.
Definition String.h:69
A TcpServer allows the software to recieve socket connections from external sources.
Definition TcpServer.h:17
static QByteArray CreateOpenFilePacket(const File &file_to_open)
static QByteArray CreateMessagePacket(const String &type, const String &data, const String &args=String())
virtual bool sendSetScreenResolution(const Vector< 2, uint04 > &size, QTcpSocket *socket=nullptr)
static QByteArray CreatRequestSendFilePacket(const File &file_to_request, const String &args=String())
static QByteArray CreateOpenAppPacket(const File &application, const String &args=String(), bool wait_for_completion=true, bool windowless=false)
virtual void socketDisconnected(QTcpSocket *socket)
virtual void showError(const Exception &e)
virtual bool sendOpenApp(const File &application, const String &args, bool wait_for_completion, bool windowless, QTcpSocket *socket=nullptr)
TcpServer(const String &server_name, QObject *parent=0)
virtual bool sendData(const String &data, QTcpSocket *socket=nullptr)
virtual bool sendError(const Exception &e, QTcpSocket *socket=nullptr)
void discardSocketSlot()
void displayErrorSlot(int socketError)
virtual bool sendPacket(const QByteArray &packet, QTcpSocket *socket=nullptr)
TcpServer(const String &server_name, uint04 port, QObject *parent=0)
virtual bool sendFile(const File &file, QTcpSocket *socket=nullptr)
void newConnectionSlot()
void connectToRemoteServer(QTcpSocket *remote_socket)
static QByteArray CreateSendErrorPacket(const Exception &e)
virtual bool dataRecieved(const String &data_type, const String &args, const String &data, QTcpSocket *socket)
virtual bool sendShowFileBrowser(QTcpSocket *socket=nullptr)
static QByteArray CreateFilePacket(const File &file, bool send_file_contents)
virtual bool sendFile(const File &file, bool send_file_contents, QTcpSocket *socket=nullptr)
void connectToRemoteServer(const String &remote_address)
virtual bool sendData(const String &data_type, const String &data, QTcpSocket *socket=nullptr)
virtual bool fileRecieved(const String &data_type, const String &args, const File &data, QTcpSocket *socket)
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
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:96