Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
session.h
Go to the documentation of this file.
1#pragma once
2
6
7#include <sonde/global.h>
8
9#include <QtCore/QDateTime>
10#include <QtCore/QJsonObject>
11#include <QtCore/QString>
12#include <QtNetwork/QHostAddress>
13
14#include <functional>
15#include <memory>
16
17namespace Sonde {
18
24{
27 qint64 pid = -1;
29 QString executable;
32 qint64 parentPid = -1;
37 QHostAddress address;
38};
39
42{
43 QString id;
44 QString transport;
45 QJsonObject clientInfo;
47 QDateTime started;
48};
49
51
59class SONDE_CORE_EXPORT SessionRequest
60{
61public:
63 SessionRequest() = default;
64
66 bool isValid() const { return d != nullptr; }
68 QString clientName() const;
70 QString clientVersion() const;
72 QJsonObject clientInfo() const;
74 QString transport() const;
76 SessionPeer peer() const;
77
79 bool isAnswered() const;
81 void approve() const;
84 void deny(const QString &reason = { }) const;
89 void onCancelled(std::function<void()> callback) const;
90
91private:
92 friend class SessionRequestPrivate;
94 explicit SessionRequest(std::shared_ptr<SessionRequestPrivate> state) : d(std::move(state)) { }
95 std::shared_ptr<SessionRequestPrivate> d;
96};
97
100using SessionApproval = std::function<void(const SessionRequest &request)>;
101
102} // namespace Sonde
Shared state behind SessionRequest handles (design 0033).
Definition server_p.h:87
A client asking to start a session, for the application to approve or refuse (see Server::setSessionA...
Definition session.h:60
SessionRequest(std::shared_ptr< SessionRequestPrivate > state)
Wraps the shared state (created by the server).
Definition session.h:94
SessionRequest()=default
An invalid request; every operation on it does nothing.
std::shared_ptr< SessionRequestPrivate > d
Shared request state.
Definition session.h:95
bool isValid() const
Whether this refers to a request.
Definition session.h:66
What every Sonde header includes: the version, and the deprecation macros (design 0031).
Embeddable Model Context Protocol server for Qt applications.
Definition dispatch.cpp:10
std::function< void(const SessionRequest &request)> SessionApproval
Decides about a client asking to start a session: calls approve() or deny() on request,...
Definition session.h:100
A connected client, as Server::sessions() lists it.
Definition session.h:42
SessionPeer peer
What the operating system says about it.
Definition session.h:46
QString id
The session's id, for Server::endSession().
Definition session.h:43
QDateTime started
When it was let in.
Definition session.h:47
QString transport
"local" or "http".
Definition session.h:44
QJsonObject clientInfo
The clientInfo it sent with initialize: what it says it is.
Definition session.h:45
What the operating system says about a client, as far as Sonde can learn it.
Definition session.h:24
QString parentExecutable
The program the parent runs, as a full path.
Definition session.h:34
QHostAddress address
The remote address of an HTTP client (null for the local socket).
Definition session.h:37
QString executable
The program that process runs, as a full path.
Definition session.h:29
qint64 parentPid
That process's parent: for a client behind sonde-bridge, the agent that started the bridge.
Definition session.h:32
qint64 pid
The process at the other end of the local socket (-1 over HTTP).
Definition session.h:27