SDK
SDK C++ v1.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

This SDK has been deprecated because of stability issues. It is not advised to use it in a production environment.

publish #

Sends a real-time message to Kuzzle. The message will be dispatched to all clients with subscriptions matching the index, the collection and the message content.

The index and collection are indicative and serve only to distinguish the rooms. They are not required to exist in the database

Note: real-time messages are not persisted in the database.

Signature #

void publish(
    const std::string& index,
    const std::string& collection,
    const std::string& message);

void publish(
    const std::string& index,
    const std::string& collection,
    const std::string& message,
    const kuzzleio::query_options& options);

Arguments #

ArgumentsTypeDescription
index
const std::string&
Index name
collection
const std::string&
Collection name
message
const std::string&
JSON string representing a JSON payload
options
kuzzleio::query_options*
Query options

options #

Additional query options

OptionType
(default)
Description
queuable
bool

(true)
If true, queues the request during downtime, until connected to Kuzzle again
volatiles
const char*

("{}")
JSON string representing subscription information, used in user join/leave notifications

Exceptions #

Throws a kuzzleio::KuzzleException if there is an error. See how to handle error.

Usage #

try {
  std::string message = R"({ "realtime": "rule the web" })";
  kuzzle->realtime->publish("i-dont-exist", "in-database", message);
  std::cout << "Message successfully published" << std::endl;
} catch (kuzzleio::KuzzleException &e) {
  std::cerr << e.what() << std::endl;
}