From 8a23aa89a58d3a90d5851b449b5552e1fcdcaded Mon Sep 17 00:00:00 2001 From: rtk0c Date: Mon, 27 Jun 2022 00:13:08 +0000 Subject: (From git) Initial server setup git-svn-id: file:///home/arch/svn/epistmool/trunk@4 71f44415-077c-4ad7-a976-72ddbf76608f --- server-v1/source/EpistmoolServer/Connection.hpp | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 server-v1/source/EpistmoolServer/Connection.hpp (limited to 'server-v1/source/EpistmoolServer/Connection.hpp') diff --git a/server-v1/source/EpistmoolServer/Connection.hpp b/server-v1/source/EpistmoolServer/Connection.hpp new file mode 100644 index 0000000..78e34db --- /dev/null +++ b/server-v1/source/EpistmoolServer/Connection.hpp @@ -0,0 +1,50 @@ +#pragma once + +#include +#include + +class QLocalServer; +class QJsonDocument; + +namespace Epistmool::Server { + +struct ConnectionId +{ + int index; + int generation; + + static ConnectionId createInvalid(); + bool isInvalid() const; + + bool operator==(const ConnectionId&) const = default; +}; + +uint qHash(const ConnectionId& id, uint seed = 0); + +class ConnectionManager : public QObject +{ + Q_OBJECT + class Private; + +private: + QLocalServer* mLocal = nullptr; + + struct Connection; + std::vector mConnections; + +public: + explicit ConnectionManager(QObject* parent = nullptr); + ~ConnectionManager(); + + bool isLocalConnectionsEnabled() const; + void setLocalConnectionsEnabled(bool enabled); + + void replyMessage(ConnectionId id, const QJsonDocument& message); + +signals: + void connectionEstablished(Epistmool::Server::ConnectionId id); + void connectionDropped(Epistmool::Server::ConnectionId id); + void messageRecieved(const QJsonDocument& message, Epistmool::Server::ConnectionId id); +}; + +} // namespace Epistmool::Server -- cgit v1.2.3-70-g09d2