LightstreamerClient class
Facade class for the management of the communication to Lightstreamer Server.
Used to provide configuration settings, event
handlers, operations for the control of the connection lifecycle,
Subscription handling and to send messages.
It also provides support for mobile push notifications (MPN) via
MpnSubscription, a specific kind of subscription that
routes real-time updates via push notifications.
An instance of LightstreamerClient handles the communication with
Lightstreamer Server on a specified endpoint. Hence, it hosts one "Session";
or, more precisely, a sequence of Sessions, since any Session may fail
and be recovered, or it can be interrupted on purpose.
So, normally, a single instance of LightstreamerClient is needed.
However, multiple instances of LightstreamerClient can be used,
toward the same or multiple endpoints.
You can listen to the events generated by a session by registering an event listener, such as ClientListener or SubscriptionListener. These listeners allow you to handle various events, such as session creation, connection status, subscription updates, and server messages. However, you should be aware that the event notifications are dispatched by a single thread, the so-called event thread. This means that if the operations of a listener are slow or blocking, they will delay the processing of the other listeners and affect the performance of your application. Therefore, you should delegate any slow or blocking operations to a dedicated thread, and keep the listener methods as fast and simple as possible. Note that even if you create multiple instances of LightstreamerClient, they will all use a single event thread, that is shared among them.
Constructors
- LightstreamerClient(String? serverAddress, String? adapterSet)
- Creates an object to be configured to connect to a Lightstreamer server and to handle all the communications with it.
Properties
- connectionDetails ↔ ConnectionDetails
-
Data object that contains the details needed to open a connection to
a Lightstreamer Server.
latefinal
- connectionOptions ↔ ConnectionOptions
-
Data object that contains options and policies for the connection to
the server.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addListener(
ClientListener listener) → void - Adds a listener that will receive events from the LightstreamerClient instance.
-
connect(
) → Future< void> - Operation method that requests to open a Session against the configured Lightstreamer Server.
-
disconnect(
) → Future< void> - Operation method that requests to close the Session opened against the configured Lightstreamer Server (if any).
-
findMpnSubscription(
String subscriptionId) → Future< MpnSubscription?> - Inquiry method that returns the MpnSubscription with the specified subscription ID, or null if not found.
-
getListeners(
) → List< ClientListener> - Returns a list containing the ClientListener instances that were added to this client.
-
getMpnSubscriptions(
[String? filter]) → Future< List< MpnSubscription> > - Inquiry method that returns a collection of the existing MPN subscription with a specified status.
-
getStatus(
) → Future< String> - Inquiry method that gets the current client status and transport (when applicable).
-
getSubscriptions(
) → Future< List< Subscription> > - Inquiry method that returns a list containing all the Subscription instances that are currently "active" on this LightstreamerClient.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerForMpn(
MpnDevice device) → Future< void> - Operation method that registers the MPN device on the server's MPN Module.
-
removeListener(
ClientListener listener) → void - Removes a listener from the LightstreamerClient instance so that it will not receive events anymore.
-
sendMessage(
String message, [String? sequence, int? delayTimeout, ClientMessageListener? listener, bool? enqueueWhileDisconnected]) → Future< void> - Operation method that sends a message to the Server.
-
subscribe(
Subscription sub) → Future< void> - Operation method that adds a Subscription to the list of "active" Subscriptions. The Subscription cannot already be in the "active" state.
-
subscribeMpn(
MpnSubscription sub, bool coalescing) → Future< void> - Operation method that subscribes an MpnSubscription on server's MPN Module.
-
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribe(
Subscription sub) → Future< void> - Operation method that removes a Subscription that is currently in the "active" state.
-
unsubscribeMpn(
MpnSubscription sub) → Future< void> - Operation method that unsubscribes an MpnSubscription from the server's MPN Module.
-
unsubscribeMpnSubscriptions(
[String? filter]) → Future< void> - Operation method that unsubscribes all the MPN subscriptions with a specified status from the server's MPN Module.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
addCookies(
String uri, List< Cookie> cookies) → Future<void> - Static method that can be used to share cookies between connections to the Server (performed by this library) and connections to other sites that are performed by the application.
-
getCookies(
String uri) → Future< List< Cookie> > - Static inquiry method that can be used to share cookies between connections to the Server (performed by this library) and connections to other sites that are performed by the application.
-
setLoggerProvider(
LoggerProvider provider) → Future< void> - Static method that permits to configure the logging system used by the library.