|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
Base class for anything that produces a stream of events for MCP clients. More...
#include <eventsource.h>
Public Member Functions | |
| EventSource (QString name, QString description={ }, QObject *parent=nullptr) | |
Creates a source called name (used in filters and resource URIs), described by description in the events tools' descriptions. | |
| ~EventSource () override | |
| Destroys the source; the server forgets it. | |
| QString | name () const |
| The source's name. | |
| QString | description () const |
| Human-readable description shown in tool descriptions. | |
| void | emitEvent (LogLevel level, const QString &message, const QString &category={ }, const QJsonObject &data={ }) |
| Emits an event. | |
| void | eventOccurred (const Sonde::Event &event) |
| An event was emitted (sequence is still 0; the server assigns it). | |
Private Attributes | |
| PrivatePtr< EventSourcePrivate > | d |
| Implementation. | |
Base class for anything that produces a stream of events for MCP clients.
Events emitted by sources added to a Server are kept in a ring buffer and made available through:
Use it directly or subclass it:
|
explicit |
Creates a source called name (used in filters and resource URIs), described by description in the events tools' descriptions.
Both are fixed: the server builds the tools' descriptions from them when the source is added.
| void Sonde::EventSource::emitEvent | ( | LogLevel | level, |
| const QString & | message, | ||
| const QString & | category = { }, | ||
| const QJsonObject & | data = { } ) |
Emits an event.
Thread-safe: eventOccurred() is emitted on the calling thread, and a Server records the event there, so it is buffered even while the source's own thread is blocked. Don't destroy the source while another thread may call this.
| void Sonde::EventSource::eventOccurred | ( | const Sonde::Event & | event | ) |
An event was emitted (sequence is still 0; the server assigns it).
Emitted on the thread that called emitEvent(). Connect with a context object (the usual automatic connection) to receive it on that object's thread.