Lightstreamer C++ Client SDK
|
This C++ library enables any C++ application to communicate bidirectionally with the Lightstreamer Server. The API allows to subscribe to real-time data pushed by the server and to send any message to the server.
The library exposes a fully asynchronous API. All the API calls that require any action from the library itself are queued for processing by a dedicated thread before being carried out. The same thread is also used to carry notifications for the appropriate listeners as provided by the custom code. Blocking operations and internal housekeeping are performed on different threads.
The library offers automatic recovery from connection failures, automatic selection of the best available transport, and full decoupling of subscription and connection operations. The subscriptions are always meant as subscriptions "to the LightstreamerClient", not "to the Server"; the LightstreamerClient is responsible of forwarding the subscriptions to the Server and re-forwarding all the subscriptions whenever the connection is broken and then reopened.
The C++ library can be available depending on Edition and License Type. To know what features are enabled by your license, please see the License tab of the Monitoring Dashboard (by default, available at /dashboard).
Comprehensive guidelines for building and installation can be found here.
To ensure the proper functioning of the Client SDK, it is essential to initialize the library first. Failing to do so may result in function calls directed to the client hanging indefinitely. This initialization process activates several service threads that will continue to run until explicitly terminated .
To connect to a Lightstreamer Server, a Lightstreamer::LightstreamerClient
object has to be created, configured, and instructed to connect to the Lightstreamer Server. A minimal version of the code that creates a LightstreamerClient and connects to the Lightstreamer Server on https://push.lightstreamer.com
will look like this:
For each subscription to be subscribed to a Lightstreamer Server a Lightstreamer::Subscription
instance is needed. A simple Subscription containing three items and two fields to be subscribed in MERGE mode is easily created (see Lightstreamer General Concepts):
Before sending the subscription to the server, usually at least one Lightstreamer::SubscriptionListener
is attached to the Subscription instance in order to consume the real-time updates. The following code shows the values of the fields stock_name and last_price each time a new update is received for the subscription:
Below is the complete C++ code:
To enable the internal client logger, create an instance of Lightstreamer::LoggerProvider
and set it as the default provider of Lightstreamer::LightstreamerClient
.
To use a self-signed certificate, you typically need to configure a Trust Manager Factory with your certificate and private key. Here's a general outline of the steps you might follow:
The library is compatible with Lightstreamer Server since version 7.4.0.
For questions and support please use the Official Forum. The issue list of this page is exclusively for bug reports and feature requests.