com.lightstreamer.client

This library enables any 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.

Start digging into the API from the LightstreamerClient object. The 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).

..
ClientListener

Interface to be implemented to listen to LightstreamerClient events comprehending notifications of connection activity and errors.
Events for these listeners are dispatched by a different thread than the one that generates them. This means that, upon reception of an event, it is possible that the internal state of the client has changed. On the other hand, all the notifications for a single LightstreamerClient, including notifications to ClientListeners, SubscriptionListeners and ClientMessageListeners will be dispatched by the same thread.

ClientMessageListener

Interface to be implemented to listen to LightstreamerClient.sendMessage events reporting a message processing outcome. Events for these listeners are dispatched by a different thread than the one that generates them. All the notifications for a single LightstreamerClient, including notifications to ClientListeners, SubscriptionListeners and ClientMessageListeners will be dispatched by the same thread. Only one event per message is fired on this listener.

ConnectionDetails

Used by LightstreamerClient to provide a basic connection properties data object.

ConnectionOptions

Used by LightstreamerClient to provide an extra connection properties data object.

ItemUpdate

Contains all the information related to an update of the field values for an item. It reports all the new values of the fields.

LightstreamerClient

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.
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.

Proxy

Simple class representing a Proxy configuration.

Subscription

Class representing a Subscription to be submitted to a Lightstreamer Server. It contains subscription details and the listeners needed to process the real-time data.
After the creation, a Subscription object is in the "inactive" state. When a Subscription object is subscribed to on a LightstreamerClient object, through the LightstreamerClient.subscribe(Subscription) method, its state becomes "active". This means that the client activates a subscription to the required items through Lightstreamer Server and the Subscription object begins to receive real-time events.
A Subscription can be configured to use either an Item Group or an Item List to specify the items to be subscribed to and using either a Field Schema or Field List to specify the fields.
"Item Group" and "Item List" are defined as follows:

  • "Item Group": an Item Group is a String identifier representing a list of items. Such Item Group has to be expanded into a list of items by the getItems method of the MetadataProvider of the associated Adapter Set. When using an Item Group, items in the subscription are identified by their 1-based index within the group.
    It is possible to configure the Subscription to use an "Item Group" using the this.setItemGroup(String) method.
  • "Item List": an Item List is an array of Strings each one representing an item. For the Item List to be correctly interpreted a LiteralBasedProvider or a MetadataProvider with a compatible implementation of getItems has to be configured in the associated Adapter Set.
    Note that no item in the list can be empty, can contain spaces or can be a number.
    When using an Item List, items in the subscription are identified by their name or by their 1-based index within the list.
    It is possible to configure the Subscription to use an "Item List" using the this.setItems(String[]) method or by specifying it in the constructor.
"Field Schema" and "Field List" are defined as follows:
  • "Field Schema": a Field Schema is a String identifier representing a list of fields. Such Field Schema has to be expanded into a list of fields by the getFields method of the MetadataProvider of the associated Adapter Set. When using a Field Schema, fields in the subscription are identified by their 1-based index within the schema.
    It is possible to configure the Subscription to use a "Field Schema" using the this.setFieldSchema(String) method.
  • "Field List": a Field List is an array of Strings each one representing a field. For the Field List to be correctly interpreted a LiteralBasedProvider or a MetadataProvider with a compatible implementation of getFields has to be configured in the associated Adapter Set.
    Note that no field in the list can be empty or can contain spaces.
    When using a Field List, fields in the subscription are identified by their name or by their 1-based index within the list.
    It is possible to configure the Subscription to use a "Field List" using the this.setFields(String[]) method or by specifying it in the constructor.

SubscriptionListener

Interface to be implemented to listen to Subscription events comprehending notifications of subscription/unsubscription, updates, errors and others.
Events for these listeners are dispatched by a different thread than the one that generates them. This means that, upon reception of an event, it is possible that the internal state of the client has changed. On the other hand, all the notifications for a single LightstreamerClient, including notifications to ClientListeners, SubscriptionListeners and ClientMessageListeners will be dispatched by the same thread.