Other Push Events
This page documents connection events and request-result callbacks. See Client Lifecycle for client creation, connection, disconnection, and heartbeat handling.
Connection Established
void IPushClient::set_connected_callback(const std::function<void()> &cb)Registers a no-argument callback for an established connection. This event does not confirm any subscription.
push_client->set_connected_callback([]() { std::cout << "connected\n"; });Connection Closed
void IPushClient::set_disconnected_callback(const std::function<void()> &cb)Registers a no-argument disconnection callback. Do not destroy the client from a callback executing on its worker thread.
push_client->set_disconnected_callback([]() { std::cout << "disconnected\n"; });Transport Error
void IPushClient::set_inner_error_callback(
const std::function<void(std::string)> &cb)Receives transport-level string errors. This is the only error callback that accepts std::string.
push_client->set_inner_error_callback([](std::string message) {
std::cerr << message << '\n';
});Subscription Result
void IPushClient::set_subscribe_callback(
const std::function<void(const tigeropen::push::pb::Response&)> &cb)Receives asynchronous subscription acknowledgements. A subscription method immediately returns a locally assigned request ID; Response.id() correlates the acknowledgement with that ID. code() is the result and msg() is the server message. Returning an ID does not mean the subscription succeeded and the ID is not a market-data sequence number.
unsigned int pending_id = 0;
push_client->set_subscribe_callback([&](const tigeropen::push::pb::Response& response) {
if (response.id() == pending_id) {
std::cout << response.code() << ": " << response.msg() << '\n';
}
});
pending_id = push_client->subscribe_quote({"AAPL"});Model shape (from Response.pb.h)
| Field/accessor | Protobuf type | Description |
|---|---|---|
command() | SocketCommon.Command | Response command |
id() | uint32 | Request ID correlated with the method return value |
code() | int32 | Server result code |
msg() | string | Server message |
body() | PushData | Optional response body |
These are generated model fields, not a captured response payload. Source: include/openapi_pb/pb_source/Response.pb.h.
Unsubscription Result
void IPushClient::set_unsubscribe_callback(
const std::function<void(const tigeropen::push::pb::Response&)> &cb)Uses the same correlation semantics: match Response.id() to the request ID returned by the unsubscribe method.
push_client->set_unsubscribe_callback([](const tigeropen::push::pb::Response& response) {
std::cout << response.id() << " " << response.code() << '\n';
});
const unsigned int request_id = push_client->unsubscribe_quote({"AAPL"});Server Error
void IPushClient::set_error_callback(
const std::function<void(const tigeropen::push::pb::Response&)> &cb)Receives protocol/server errors. The old std::string callback type was incorrect; inspect Response.id(), code(), and msg().
push_client->set_error_callback([](const tigeropen::push::pb::Response& response) {
std::cerr << response.id() << " " << response.code() << " " << response.msg() << '\n';
});Connection Replaced
void IPushClient::set_kickout_callback(
const std::function<void(const tigeropen::push::pb::Response&)> &cb)Receives the protocol response when a newer session replaces this connection. The old std::string callback type was incorrect.
push_client->set_kickout_callback([](const tigeropen::push::pb::Response& response) {
std::cerr << "kickout: " << response.msg() << '\n';
});Subscribed-Symbol Query Result
void IPushClient::set_query_subscribed_symbols_changed_callback(
const std::function<void(
const tigeropen::push::pb::Response& query_subscribed_symbols_response)> &cb)Use with query_subscribed_symbols(). The method returns a request ID, Response.id() correlates the result, and the subscription data is in the response body.
push_client->set_query_subscribed_symbols_changed_callback(
[](const tigeropen::push::pb::Response& response) {
std::cout << response.id() << " " << response.body().DebugString();
});
const unsigned int request_id = push_client->query_subscribed_symbols();Heartbeat
void IPushClient::set_heartbeat_callback(const std::function<void()> &cb)Registers a no-argument callback for received heartbeats. Use it for connection-health observation, not as a replacement for the disconnection callback.
push_client->set_heartbeat_callback([]() { std::cout << "heartbeat\n"; });Permissions and Limits
Callbacks execute asynchronously; captured objects must outlive callback execution. Request IDs correlate messages only within this client connection. Subscription permissions, symbol limits, and frequency depend on the data type and account entitlements.
Updated 9 days ago
