public class LSClient
extends java.lang.Object
Constructor and Description |
---|
LSClient()
Empty constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
batchRequests(int batchSize)
Signals that the next subscription and unsubscription requests can be
accumulated and sent to Lightstreamer Server with a single connection.
|
void |
changeConstraints(ConnectionConstraints constraints)
Requests new constraints to be applied on the overall data flow
from the current connection.
|
void |
changeSubscription(SubscribedTableKey tableKey,
SubscriptionConstraints constraints)
Dynamically changes subscription parameters on a table previously
subscribed to the Server.
|
void |
changeSubscriptions(SubscribedTableKey[] tableKeys,
SubscriptionConstraints constraints)
Dynamically changes subscription parameters on a set of tables previously
subscribed to the Server.
|
void |
closeBatch()
Closes a pending batch.
|
void |
closeConnection()
Closes the connection to the Server, if one is open.
|
void |
forceUnsubscribeTable(SubscribedTableKey tableKey)
Tries to unsubscribe from a table for which a previous unsubscribe
has been called but an exception has been received.
|
void |
openConnection(ConnectionInfo info,
ConnectionListener listener)
Opens a connection to the Server with the supplied parameters.
|
int |
sendMessage(MessageInfo message,
SendMessageListener listener)
Send a message to Lightstreamer Server.
|
void |
sendMessage(java.lang.String message)
Sends a message to Lightstreamer Server.
|
SubscribedTableKey[] |
subscribeItems(ExtendedTableInfo items,
HandyTableListener listener)
Subscribes to a set of items, which share the same schema and other
subscription parameters.
|
SubscribedTableKey |
subscribeTable(ExtendedTableInfo table,
HandyTableListener listener,
boolean commandLogic)
Subscribes to a table through the Server.
|
SubscribedTableKey |
subscribeTable(SimpleTableInfo table,
HandyTableListener listener,
boolean commandLogic)
Subscribes to a table through the Server.
|
void |
unbatchRequest()
Signals that one of the requests previously scheduled for batching
is no longer going to be issued.
|
void |
unsubscribeTable(SubscribedTableKey tableKey)
Unsubscribes from a table previously subscribed to the Server.
|
void |
unsubscribeTables(SubscribedTableKey[] tableKeys)
Unsubscribes from a set of tables previously subscribed to the Server.
|
public void openConnection(ConnectionInfo info, ConnectionListener listener) throws PushConnException, PushServerException, PushUserException
ConnectionInfo
parameter. By the way, these settings will also apply
to connections used for subscriptions and other control requests.info
- Contains the Server address and the connection parameters.
A copy of the object is stored internally.listener
- Receives notification for connection events.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer.
In normal operation, this should not happen.PushUserException
- Thrown in case the Server has refused
the connection request because of the constraints imposed by the
Metadata Adapter or by Server configuration.public void closeConnection()
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.public void sendMessage(java.lang.String message) throws PushConnException, PushServerException, PushUserException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.
sendMessage(MessageInfo, SendMessageListener)
to send a batch of messagesmessage
- Any text string, to be interpreted by the Metadata
Adapter. It should not be null.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer.
In normal conditions, this exception should never happen.PushUserException
- Thrown in case the Server has refused
the message because of the constraints imposed by the Metadata Adapter
or by Server configuration.public int sendMessage(MessageInfo message, SendMessageListener listener) throws PushConnException, PushServerException, PushUserException
SendMessageListener
instance. Unless the return value is 0, one of those events will be eventually sent. Calls associated with
the same sequence are guaranteed to be issued in sequence.message
- An instance containing the message string to be interpreted by the Metadata Adapter, the sequence
this message has to be associated with and a delay timeout to be waited by the server for missing previous messages
to be received before being declared lost.listener
- A listener instance to receive a call representing the outcome of the message request.SendMessageListener.onAbort(com.lightstreamer.ls_client.MessageInfo, int, java.lang.Exception)
will be made.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer.
In normal conditions, this exception should never happen.PushUserException
- Thrown in case the Server has refused
the message because of the constraints imposed by the Metadata Adapter
or by Server configuration.public void changeConstraints(ConnectionConstraints constraints) throws PushConnException, PushServerException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.constraints
- Collects available constraints.
It should not be null; to unset all
constraints, use an empty structure, instead.
A copy of the object is stored internally.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer.
In normal conditions, this exception should never happen.public SubscribedTableKey subscribeTable(SimpleTableInfo table, HandyTableListener listener, boolean commandLogic) throws SubscrException, PushServerException, PushUserException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.table
- Contains the specification and request parameters
of the table to subscribe to.listener
- Receives notification of data updates and subscription
termination.commandLogic
- if true, enables the management of item values
in "COMMAND logic", as specified in HandyTableListener
.
This requires that the items are subscribed to in COMMAND mode or
behave equivalently. This also requires that the special "key" and
"command" fields are the first and second field in the schema,
respectively.SubscrException
- Thrown if the connection is closed.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer.
In normal conditions, this exception should never happen.PushUserException
- Thrown in case the subscription was refused
after the checks in Lightstreamer Server Metadata Adapter.public SubscribedTableKey subscribeTable(ExtendedTableInfo table, HandyTableListener listener, boolean commandLogic) throws SubscrException, PushServerException, PushUserException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.table
- Contains the specification and request parameters
of the table to subscribe to.
A copy of the object is stored internally.listener
- Receives notification of data updates and subscription
termination.commandLogic
- if true, enables the notification of item updates
with "COMMAND logic", as specified in HandyTableListener
.
This requires that the items are subscribed to in COMMAND mode or
behave equivalently; in particular, that the special "key" and "command"
fields are included in the schema.SubscrException
- Thrown if the connection is closed.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer.
In normal conditions, this exception should never happen.PushUserException
- Thrown in case the subscription was refused
after the checks in Lightstreamer Server Metadata Adapter.public SubscribedTableKey[] subscribeItems(ExtendedTableInfo items, HandyTableListener listener) throws SubscrException, PushServerException, PushUserException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.items
- Contains the specification and request parameters
of the items to subscribe to. The structure is the same as that used in
subscribeTable, but the items will not be subscribed to as a table.
A copy of the object is stored internally.listener
- Receives notification of data updates and subscription
termination.SubscrException
- Thrown if the connection is closed.PushConnException
- Thrown in case of connection problems.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer. In this case, some zombie subscriptions
may remain in the Server.
In normal conditions, this exception should never happen.PushUserException
- Thrown in case the subscription was refused
after the checks in Lightstreamer Server Metadata Adapter.public void changeSubscription(SubscribedTableKey tableKey, SubscriptionConstraints constraints) throws SubscrException, PushServerException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details
on timeout settings. This kind of request is not included in a batch.tableKey
- Handle to a table as returned by a subscribe* call.constraints
- Collects available constraints. It should not be null.SubscrException
- Thrown if the supplied table is not currently
subscribed. This occurs also if the table has already been unsubscribed
or the connection has already been closed; this may not be a problem
from the client's point of view.PushConnException
- Thrown in case of connection problems.
In this case, the request may or may not have been fulfilled by the Server.PushServerException
- Thrown in case the Server refuses the request.public void changeSubscriptions(SubscribedTableKey[] tableKeys, SubscriptionConstraints constraints) throws SubscrException, PushServerException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details
on timeout settings. This kind of request is not included in a batch.tableKeys
- Array of handles to tables as returned by one or more
subscribe* calls.constraints
- Collects available constraints. It should not be null.SubscrException
- Thrown if the connection has already been
closed; this may not be a problem from the client's point of view.PushConnException
- Thrown in case of connection problems.
In this case, the request may or may not have been fulfilled by the Server.PushServerException
- Thrown in case the Server refuses the request.
Note that if changing the max frequency and any of the involved tables
has been subscribed to as unfiltered, the whole request will be refused.
Including any tables already unsubscribed from the Server may also cause
this exception; in this case, the request may have been partially fulfilled.public void unsubscribeTable(SubscribedTableKey tableKey) throws SubscrException, PushServerException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.tableKey
- Handle to a table as returned by a subscribe* call.SubscrException
- Thrown if the supplied table is not currently
subscribed. This occurs also if the table has already been unsubscribed
or the connection has already been closed; this may not be a problem
from the client's point of view.PushConnException
- Thrown in case of connection problems.
In this case, a zombie subscription will probably remain in the Server.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer. In this case, a zombie subscription
may remain in the Server.
In normal conditions, this exception should never happen.public void unsubscribeTables(SubscribedTableKey[] tableKeys) throws SubscrException, PushServerException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details on timeout settings.tableKeys
- Array of handles to tables as returned by one
or more subscribe* calls.SubscrException
- Thrown if the connection has already been
closed; this may not be a problem from the client's point of view.PushConnException
- Thrown in case of connection problems.
In this case, zombie subscriptions will probably remain in the Server.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer. In this case, some zombie subscriptions
may remain in the Server.
In normal conditions, this exception should never happen.public void forceUnsubscribeTable(SubscribedTableKey tableKey) throws SubscrException, PushServerException, PushConnException
openConnection(com.lightstreamer.ls_client.ConnectionInfo, com.lightstreamer.ls_client.ConnectionListener)
for details
on timeout settings. This kind of request is not included in a batch.tableKey
- Handle to a table as returned by a subscribe* call.SubscrException
- Thrown if the connection has already been
closed or the supplied table is currently subscribed. In this case,
there wasn't a zombie subscription in the Server for the supplied
table.PushConnException
- Thrown in case of connection problems.
In this case, nothing has changed in the Server.PushServerException
- Thrown in case of errors in the supplied
parameters or in Server answer. In this case there wasn't a zombie
subscription in the Server for the supplied table.public void batchRequests(int batchSize) throws SubscrException
batchSize
- number of incoming subscription and unsubscription
requests that can be batched. A zero value means an unlimited number
of requests (the batch must be closed by calling closeBatch).SubscrException
- Thrown if the connection is currently closed.public void unbatchRequest()
public void closeBatch()