1#ifndef INCLUDED_Lightstreamer_LightstreamerClient
2#define INCLUDED_Lightstreamer_LightstreamerClient
4#include "../Lightstreamer.h"
5#include "Lightstreamer/LoggerProvider.h"
6#include "Lightstreamer/Subscription.h"
7#include "Lightstreamer/ConnectionOptions.h"
8#include "Lightstreamer/ConnectionDetails.h"
9#include "Lightstreamer/LightstreamerError.h"
11namespace Lightstreamer {
46 static const char*
initialize(
void (*unhandledExceptionCallback)(
const char *exceptionInfo) =
nullptr) {
47 return Lightstreamer_initializeHaxeThread(unhandledExceptionCallback);
62 Lightstreamer_stopHaxeThreadIfRunning(
true);
68 return LightstreamerClient_getLibName();
74 return LightstreamerClient_getLibVersion();
113 LightstreamerClient_setLoggerProvider(provider);
134 static void addCookies(
const std::string& uri,
const std::vector<std::string>& cookies){
135 LightstreamerClient_addCookies(&uri, &cookies);
148 static std::vector<std::string>
getCookies(
const std::string& uri) {
149 return LightstreamerClient_getCookies(&uri);
162 static void setTrustManagerFactory(
const std::string& caFile,
const std::string& certificateFile,
const std::string& privateKeyFile =
"",
const std::string& password =
"",
bool verifyCert =
true) {
163 LightstreamerClient_setTrustManagerFactory(&caFile, &certificateFile, &privateKeyFile, &password, verifyCert);
205 _client = LightstreamerClient_new(&serverAddress, &adapterSet);
211 LightstreamerClient_disconnect(_client);
212 Lightstreamer_releaseHaxeObject(_client);
228 if (listener ==
nullptr)
230 LightstreamerClient_addListener(_client, listener);
245 if (listener ==
nullptr)
247 LightstreamerClient_removeListener(_client, listener);
256 return LightstreamerClient_getListeners(_client);
281 LightstreamerClient_connect(_client);
298 LightstreamerClient_disconnect(_client);
324 return LightstreamerClient_getStatus(_client);
346 if (subscription ==
nullptr)
348 LightstreamerClient_subscribe(_client, subscription->_delegate);
364 if (subscription ==
nullptr)
366 LightstreamerClient_unsubscribe(_client, subscription->_delegate);
378 return LightstreamerClient_getSubscriptions(_client);
446 void sendMessage(
const std::string& message,
const std::string& sequence =
"",
int delayTimeout = -1,
ClientMessageListener* listener =
nullptr,
bool enqueueWhileDisconnected =
false) {
447 LightstreamerClient_sendMessage(_client, &message, &sequence, delayTimeout, listener, enqueueWhileDisconnected);
Interface to be implemented to listen to LightstreamerClient events comprehending notifications of co...
Definition ClientListener.h:17
Interface to be implemented to listen to LightstreamerClient#sendMessage events reporting a message p...
Definition ClientMessageListener.h:16
Used by LightstreamerClient to provide a basic connection properties data object.
Definition ConnectionDetails.h:18
Used by LightstreamerClient to provide an extra connection properties data object.
Definition ConnectionOptions.h:18
Facade class for the management of the communication to Lightstreamer Server.
Definition LightstreamerClient.h:34
std::vector< Subscription * > getSubscriptions()
Inquiry method that returns a list containing all the Subscription instances that are currently "acti...
Definition LightstreamerClient.h:377
static void addCookies(const std::string &uri, const std::vector< std::string > &cookies)
Static method that can be used to share cookies between connections to the Server (performed by this ...
Definition LightstreamerClient.h:134
static void setLoggerProvider(LoggerProvider *provider)
Static method that permits to configure the logging system used by the library.
Definition LightstreamerClient.h:112
std::vector< ClientListener * > getListeners()
Returns a list containing the ClientListener instances that were added to this client.
Definition LightstreamerClient.h:255
ConnectionDetails connectionDetails
Data object that contains the details needed to open a connection to a Lightstreamer Server.
Definition LightstreamerClient.h:180
static std::string libVersion()
The version of the library.
Definition LightstreamerClient.h:73
static std::string libName()
The name of the library.
Definition LightstreamerClient.h:67
void subscribe(Subscription *subscription)
Operation method that adds a Subscription to the list of "active" Subscriptions.
Definition LightstreamerClient.h:345
void unsubscribe(Subscription *subscription)
Operation method that removes a Subscription that is currently in the "active" state.
Definition LightstreamerClient.h:363
static std::vector< std::string > getCookies(const std::string &uri)
Static inquiry method that can be used to share cookies between connections to the Server (performed ...
Definition LightstreamerClient.h:148
void sendMessage(const std::string &message, const std::string &sequence="", int delayTimeout=-1, ClientMessageListener *listener=nullptr, bool enqueueWhileDisconnected=false)
Operation method that sends a message to the Server.
Definition LightstreamerClient.h:446
ConnectionOptions connectionOptions
Data object that contains options and policies for the connection to the server.
Definition LightstreamerClient.h:172
void removeListener(ClientListener *listener)
Removes a listener from the LightstreamerClient instance so that it will not receive events anymore.
Definition LightstreamerClient.h:244
static void stop()
Stops the Lightstreamer thread, blocking until the thread has completed.
Definition LightstreamerClient.h:61
static const char * initialize(void(*unhandledExceptionCallback)(const char *exceptionInfo)=nullptr)
Initializes a thread that executes the Lightstreamer functions.
Definition LightstreamerClient.h:46
void disconnect()
Operation method that requests to close the Session opened against the configured Lightstreamer Serve...
Definition LightstreamerClient.h:297
void connect()
Operation method that requests to open a Session against the configured Lightstreamer Server.
Definition LightstreamerClient.h:280
std::string getStatus()
Inquiry method that gets the current client status and transport (when applicable).
Definition LightstreamerClient.h:323
static void setTrustManagerFactory(const std::string &caFile, const std::string &certificateFile, const std::string &privateKeyFile="", const std::string &password="", bool verifyCert=true)
Provides a mean to control the way TLS certificates are evaluated, with the possibility to accept unt...
Definition LightstreamerClient.h:162
void addListener(ClientListener *listener)
Adds a listener that will receive events from the LightstreamerClient instance.
Definition LightstreamerClient.h:227
LightstreamerClient(const std::string &serverAddress="", const std::string &adapterSet="")
Creates an object to be configured to connect to a Lightstreamer server and to handle all the communi...
Definition LightstreamerClient.h:204
The LightstreamerError class provides a base class for exceptions thrown by the library.
Definition LightstreamerError.h:12
Simple interface to be implemented to provide custom log consumers to the library.
Definition LoggerProvider.h:14
Class representing a Subscription to be submitted to a Lightstreamer Server.
Definition Subscription.h:56