2#include <NDEVR/Buffer.h>
3#include <NDEVR/String.h>
22 class NDEVR_NETWORK_PROTOCOLS_API
TcpServer :
public QObject
135 virtual bool sendFile(
const File& file,
bool send_file_contents, QTcpSocket* socket =
nullptr);
158 virtual bool sendOpenApp(
const File& application,
const String& args,
bool wait_for_completion,
bool windowless, QTcpSocket* socket =
nullptr);
180 virtual bool sendPacket(
const QByteArray& packet, QTcpSocket* socket =
nullptr);
Defines cross-platform DLL export/import macros for the NDEVRNetworkProtocols module.
The equivelent of std::vector but with a bit more control.
Provides consistent interface to handle errors through the throw expression.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
virtual void showError(const Exception &e)
Displays or logs an error from an exception; override for custom error handling.
void readSocketSlot()
Slot invoked when data is available to read from a connected socket.
void discardSocketSlot()
Slot invoked when a socket is disconnected and should be discarded.
virtual bool sendFile(const File &file, QTcpSocket *socket=nullptr)
Sends a file (metadata and contents) to the specified socket or all connected sockets.
static constexpr StringView error_data_message
Message type for error messages.
static constexpr StringView open_file_message_type
Message type to open a file remotely.
void connectToRemoteServer(QTcpSocket *remote_socket)
Connects to a remote TcpServer using an existing QTcpSocket.
void newConnectionSlot()
Slot invoked when a new incoming TCP connection is established.
virtual bool sendData(const StringView &data, QTcpSocket *socket=nullptr)
Sends a generic data string to the specified socket or all connected sockets.
static constexpr StringView start_application_file_message_type
Message type to start an application remotely.
virtual bool dataReceived(const String &data_type, const String &args, const String &data, QTcpSocket *socket)
Called when a data message is received from a connected socket.
static QByteArray CreateOpenFilePacket(const File &file_to_open)
Creates a packet instructing the remote end to open a file in its default handler.
virtual bool sendError(const Exception &e, QTcpSocket *socket=nullptr)
Sends an error message to the specified socket or all connected sockets.
static constexpr StringView open_os_settings
Message type to open OS settings on the remote end.
static constexpr StringView set_screen_resolution
Message type to set screen resolution remotely.
virtual bool sendFile(const File &file, bool send_file_contents, QTcpSocket *socket=nullptr)
Sends a file with control over whether contents are included.
virtual bool fileReceived(const String &data_type, const String &args, const File &data, QTcpSocket *socket)
Called when a file message is received from a connected socket.
virtual bool sendSetScreenResolution(const Vector< 2, uint04 > &size, QTcpSocket *socket=nullptr)
Sends a command to set the screen resolution on the remote end.
static QByteArray CreateFilePacket(const File &file, bool send_file_contents)
Creates a file transfer packet.
static QByteArray CreateSendErrorPacket(const Exception &e)
Creates a packet containing an error message to send to the remote end.
void connectToRemoteServer(const String &remote_address)
Connects to a remote TcpServer at the given address string.
static QByteArray CreateMessagePacket(const StringView &type, const StringView &data, const StringView &args=StringView())
Creates a message packet with the given type, data, and optional arguments.
virtual void socketDisconnected(QTcpSocket *socket)
Called when a socket has been disconnected; override to handle cleanup.
virtual bool sendPacket(const QByteArray &packet, QTcpSocket *socket=nullptr)
Sends a raw pre-built packet to the specified socket or all connected sockets.
virtual bool sendOpenApp(const File &application, const String &args, bool wait_for_completion, bool windowless, QTcpSocket *socket=nullptr)
Sends a command to launch an application on the remote end.
virtual bool sendShowFileBrowser(QTcpSocket *socket=nullptr)
Sends a command to show a file browser on the remote end.
virtual bool sendData(const StringView &data_type, const StringView &data, QTcpSocket *socket=nullptr)
Sends a typed data message to the specified socket or all connected sockets.
static constexpr StringView generic_file_message_type
Message type for generic file transfers.
TcpServer(const String &server_name, QObject *parent=0)
Constructs a TcpServer without binding to a port (client-only or deferred listen).
static QByteArray CreateOpenAppPacket(const File &application, const String &args=String(), bool wait_for_completion=true, bool windowless=false)
Creates a packet instructing the remote end to launch an application.
static constexpr StringView generic_data_message_type
Message type for generic data payloads.
TcpServer(const String &server_name, uint04 port, QObject *parent=0)
Constructs a TcpServer that listens on the specified port.
void displayErrorSlot(int socketError)
Slot invoked when a socket error occurs.
static QByteArray CreateRequestSendFilePacket(const File &file_to_request, const String &args=String())
Creates a packet requesting the remote end to send a specific file back.
static constexpr StringView request_send_file
Message type to request a file from the remote end.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
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...