diff options
author | rtk0c <[email protected]> | 2022-06-27 00:13:08 +0000 |
---|---|---|
committer | rtk0c <[email protected]> | 2022-06-27 00:13:08 +0000 |
commit | 8a23aa89a58d3a90d5851b449b5552e1fcdcaded (patch) | |
tree | 86a527705eafe1ba36d6d5744afeddad196c0eeb /server-v1/source/EpistmoolServer/Connection.hpp | |
parent | 9ad9af9f2596b91e1dd65e71543f75b0644e8283 (diff) |
(From git) Initial server setup
git-svn-id: file:///home/arch/svn/epistmool/trunk@4 71f44415-077c-4ad7-a976-72ddbf76608f
Diffstat (limited to 'server-v1/source/EpistmoolServer/Connection.hpp')
-rw-r--r-- | server-v1/source/EpistmoolServer/Connection.hpp | 50 |
1 files changed, 50 insertions, 0 deletions
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 <QObject> +#include <vector> + +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<Connection> 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 |