Sonde
v1.1.0
Embeddable Model Context Protocol server for Qt applications
Toggle main menu visibility
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
17
namespace
Sonde
{
18
23
struct
SessionPeer
24
{
27
qint64
pid
= -1;
29
QString
executable
;
32
qint64
parentPid
= -1;
34
QString
parentExecutable
;
37
QHostAddress
address
;
38
};
39
41
struct
SessionInfo
42
{
43
QString
id
;
44
QString
transport
;
45
QJsonObject
clientInfo
;
46
SessionPeer
peer
;
47
QDateTime
started
;
48
};
49
50
class
SessionRequestPrivate
;
51
59
class
SONDE_CORE_EXPORT
SessionRequest
60
{
61
public
:
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
91
private
:
92
friend
class
SessionRequestPrivate;
94
explicit
SessionRequest
(std::shared_ptr<SessionRequestPrivate> state) :
d
(std::move(state)) { }
95
std::shared_ptr<SessionRequestPrivate>
d
;
96
};
97
100
using
SessionApproval
= std::function<void(
const
SessionRequest
&request)>;
101
102
}
// namespace Sonde
Sonde::SessionRequestPrivate
Shared state behind SessionRequest handles (design 0033).
Definition
server_p.h:87
Sonde::SessionRequest
A client asking to start a session, for the application to approve or refuse (see Server::setSessionA...
Definition
session.h:60
Sonde::SessionRequest::SessionRequest
SessionRequest(std::shared_ptr< SessionRequestPrivate > state)
Wraps the shared state (created by the server).
Definition
session.h:94
Sonde::SessionRequest::SessionRequest
SessionRequest()=default
An invalid request; every operation on it does nothing.
Sonde::SessionRequest::d
std::shared_ptr< SessionRequestPrivate > d
Shared request state.
Definition
session.h:95
Sonde::SessionRequest::isValid
bool isValid() const
Whether this refers to a request.
Definition
session.h:66
global.h
What every Sonde header includes: the version, and the deprecation macros (design 0031).
Sonde
Embeddable Model Context Protocol server for Qt applications.
Definition
dispatch.cpp:10
Sonde::SessionApproval
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
Sonde::SessionInfo
A connected client, as Server::sessions() lists it.
Definition
session.h:42
Sonde::SessionInfo::peer
SessionPeer peer
What the operating system says about it.
Definition
session.h:46
Sonde::SessionInfo::id
QString id
The session's id, for Server::endSession().
Definition
session.h:43
Sonde::SessionInfo::started
QDateTime started
When it was let in.
Definition
session.h:47
Sonde::SessionInfo::transport
QString transport
"local" or "http".
Definition
session.h:44
Sonde::SessionInfo::clientInfo
QJsonObject clientInfo
The clientInfo it sent with initialize: what it says it is.
Definition
session.h:45
Sonde::SessionPeer
What the operating system says about a client, as far as Sonde can learn it.
Definition
session.h:24
Sonde::SessionPeer::parentExecutable
QString parentExecutable
The program the parent runs, as a full path.
Definition
session.h:34
Sonde::SessionPeer::address
QHostAddress address
The remote address of an HTTP client (null for the local socket).
Definition
session.h:37
Sonde::SessionPeer::executable
QString executable
The program that process runs, as a full path.
Definition
session.h:29
Sonde::SessionPeer::parentPid
qint64 parentPid
That process's parent: for a client behind sonde-bridge, the agent that started the bridge.
Definition
session.h:32
Sonde::SessionPeer::pid
qint64 pid
The process at the other end of the local socket (-1 over HTTP).
Definition
session.h:27
src
core
sonde
session.h
Generated by
1.18.0