Pages
API Documentation
On this page

Sonic::Ipc::Client Class

Connects to a Server. More...

  • Header: #include <Sonic/Ipc/Client>
  • CMake: find_package(SonicIpc REQUIRED)
    target_link_libraries(mytarget PRIVATE Sonic::Ipc)
  • Inherits: QObject

List of all members, including inherited members

Public Functions

Signals

Static Public Members

Detailed Description

Long-lived subscribers can turn on automatic reconnection; it stops for good once the server rejects this side's protocol version.

Member Function Documentation

[explicit] Client::Client(quint16 protocolVersion, qint64 maxPayload = defaultMaxPayload, QObject *parent = nullptr)

Creates a client that speaks application protocol protocolVersion and rejects payloads larger than maxPayload bytes, with the given parent.

void Client::connectToServer(const QString &nameOrPath)

Connects to the server at nameOrPath, as QLocalSocket::connectToServer() takes it; connected() or connectionFailed() follows.

[signal] void Client::connected(Sonic::Ipc::Connection *connection)

The client connected; connection belongs to the client.

Sonic::Ipc::Connection *Client::connection() const

The current connection; null while not connected.

[signal] void Client::connectionFailed(const QString &reason)

Connecting failed, for the given reason.

void Client::disconnectFromServer()

Stops reconnecting and closes the connection.

[static] std::optional<Sonic::Ipc::Frame> Client::request(const QString &nameOrPath, quint32 type, QByteArrayView payload, quint16 protocolVersion, int timeoutMs, QString *error, qint64 maxPayload = defaultMaxPayload)

Blocking request for threads without an event loop: connects to nameOrPath, sends one frame of type with payload in protocol protocolVersion and waits for one reply, all within timeoutMs (-1: no timeout). Replies larger than maxPayload bytes are rejected. The socket is created on the calling thread.

On failure it returns nothing and sets error, when it isn't null.

void Client::setReconnectInterval(int msecs)

Reconnects msecs after a failed connect or a disconnect; 0, the default, turns it off.

[signal] void Client::versionRejected(quint16 serverVersion)

The server rejected this side's protocol version; it speaks serverVersion. The client stops reconnecting.

We use cookies to personalize content and to analyze our traffic. Please decide if you are willing to accept cookies from our website.