Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::QmlDebug::anonymous_namespace{qmldebugclient.cpp}::Client Class Reference

The client: the socket, the handshake, and the queries in flight. More...

Inheritance diagram for Sonde::QmlDebug::anonymous_namespace{qmldebugclient.cpp}::Client:

Classes

struct  Pending
 A query waiting for its answer. More...

Public Types

enum class  State { Off , Connecting , Ready , Failed }
 What the connection is doing.
using Reply = std::function<void(QDataStream *answer, const QString &error)>
 Called with an answer's stream (after its type and id), or nullptr on failure.

Public Member Functions

void start ()
 See QmlDebug::start().
bool isAvailable () const
 See QmlDebug::isAvailable().
QString status () const
 See QmlDebug::status().
void query (const QByteArray &type, const std::function< void(QDataStream &)> &arguments, QObject *context, Reply reply)
 Sends type with query id and arguments to the service; reply gets the answer.

Private Member Functions

std::optional< Pending > takePending (qint32 id)
 Removes and returns query id, if it is still waiting.
void fail (const QString &why)
 Stops for good, with why as the status; fails every query in flight.
void sendWaiting ()
 Sends (or fails) the queries made while connecting.
void accept ()
 The debug connector connected: say hello.
void send (const QByteArray &data)
 Sends one packet: its size, then data.
void readPackets ()
 Takes every whole packet off the socket.
void handlePacket (const QByteArray &packet)
 One packet: the handshake's answer, or the service's messages.
void handleMessage (const QByteArray &message)
 One message of the engine service: an answer to a query.

Private Attributes

QLocalServer m_server
 Where the debug connector connects.
QPointer< QLocalSocket > m_socket
 The connection, once there is one.
QByteArray m_buffer
 Bytes of a packet still arriving.
QDataStream::Version m_version
 Agreed in the handshake.
QHash< qint32, Pending > m_pending
 Queries waiting for answers, by id.
QList< std::function< void()> > m_waiting
 Queries made while connecting.
qint32 m_nextQueryId = 1
 Id of the next query.
State m_state = State::Off
 What the connection is doing.
QString m_status
 Why it isn't available.
bool m_started = false
 Whether start() ran.

Detailed Description

The client: the socket, the handshake, and the queries in flight.

Member Data Documentation

◆ m_status

QString Sonde::QmlDebug::anonymous_namespace{qmldebugclient.cpp}::Client::m_status
private
Initial value:
= QStringLiteral(
"off: installQuickIntegration() turns it on")

Why it isn't available.

◆ m_version

QDataStream::Version Sonde::QmlDebug::anonymous_namespace{qmldebugclient.cpp}::Client::m_version
private
Initial value:
=
QDataStream::Qt_DefaultCompiledVersion

Agreed in the handshake.


The documentation for this class was generated from the following file: