|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.lightstreamer.javameclient.midp.LSClient
public class LSClient
Incapsulates a single connector to Lightstreamer Server. Since mobile's JVM have small capabilities, we advise to use only one instance of LSClient per MIDlet.
| Nested Class Summary | |
|---|---|
static class |
LSClient.Util
Class Util. |
| Field Summary | |
|---|---|
static java.lang.String |
CONNECTING
String constant for the "connecting" status of LSClient: The Client is trying to reach Lightstreamer Server. |
static boolean |
isMidp2
Boolean value that can be tested to know whenever the application is running with MIDP 1.0 or MIDP 2.0 library. |
static java.lang.String |
OFF
String constant for the "off" status of LSClient: The Client is waiting for connection commands. |
static java.lang.String |
POLLING
Represent the polling status of LSClient. |
static java.lang.String |
STALLED
String constant for the "stalled" status of LSClient: The Client was receiving data from a Lightstreamer Server but it now seems to be isolated. |
static java.lang.String |
STREAMING
String constant for the "streaming" status of LSClient: The Client is receiving real-time updates from Lightstreamer Server. |
| Constructor Summary | |
|---|---|
LSClient()
Constructor LSClient. |
|
| Method Summary | |
|---|---|
static void |
closeApp()
Calling this method will stops all the LSClient's thread. |
void |
closeConnection()
Closes the connection to the Server, if one is open. |
java.lang.String |
getStatus()
Inquiry method that gets the current client status. |
void |
openConnection(ConnectionInfo info,
ConnectionListener listener)
Open a stream connection to the Server with the supplied parameters and default policies. |
void |
openConnection(ConnectionInfo info,
ConnectionListener listener,
ConnectionPolicy policy)
Open a stream connection to the Server with the supplied parameters and policies. |
void |
openPollingConnection(ConnectionInfo info,
ConnectionListener listener)
Open a poll connection to the Server with the supplied parameters and default policies. |
void |
openPollingConnection(ConnectionInfo info,
ConnectionListener listener,
ConnectionPolicy policy)
Open a poll connection to the Server with the supplied parameters and policies. |
boolean |
sendMessage(java.lang.String message)
Send a message to Lightstreamer Server. |
void |
setBandwidthUnlimited()
Request unlimited bandwidth for the next/current connection. |
void |
setBufferMax(int bufferMax)
This method establishes how large the Client buffer must be. |
void |
setMaxBandwidth(int maxBandwidth)
Request a new maximum bandwidth for the next/current connection. |
SubscribedTableKey |
subscribeTable(ExtendedTableInfo info,
ExtendedTableListener tListener)
Subscribes to a table through the Server. |
SubscribedTableKey |
subscribeTable(ExtendedTableInfo info,
HandyTableListener tListener,
boolean commandLogic)
Subscribes to a table through the Server. |
SubscribedTableKey |
subscribeTable(SimpleTableInfo info,
HandyTableListener tListener,
boolean commandLogic)
Subscribes to a table through the Server. |
SubscribedTableKey |
subscribeTable(SimpleTableInfo info,
SimpleTableListener tListener)
Subscribes to a table through the Server. |
java.lang.String |
toString()
Method toString. |
void |
unsubscribeTable(SubscribedTableKey key)
Unsubscribes from a table previously subscribed to. |
void |
useReusableItemUpdates(boolean useReusable)
This method establishes if the LSClient instance will use SimpleItemUpdate and ExtendedItemUpdate
or ReusableSimpleItemUpdate and ReusableExtendedItemUpdate. |
void |
useSingleConnection(boolean useOneConnection)
This method establish if LSClient will use one or more connections to comunicate with Lightstreamer Server. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String OFF
getStatus(),
ConnectionListener.onStatusChange(String),
Constant Field Valuespublic static final java.lang.String CONNECTING
getStatus(),
ConnectionListener.onStatusChange(String),
Constant Field Valuespublic static final java.lang.String STREAMING
getStatus(),
openConnection(ConnectionInfo, ConnectionListener),
openConnection(ConnectionInfo, ConnectionListener, ConnectionPolicy),
ConnectionListener.onStatusChange(String),
Constant Field Valuespublic static final java.lang.String STALLED
getStatus(),
ConnectionListener.onStatusChange(String),
ConnectionPolicy.setTimeoutForStalled(int),
ConnectionPolicy.setKeepAliveInterval(int),
Constant Field Valuespublic static final java.lang.String POLLING
getStatus(),
openPollingConnection(ConnectionInfo, ConnectionListener),
openPollingConnection(ConnectionInfo, ConnectionListener, ConnectionPolicy),
ConnectionListener.onStatusChange(String),
Constant Field Valuespublic static final boolean isMidp2
| Constructor Detail |
|---|
public LSClient()
| Method Detail |
|---|
public void useSingleConnection(boolean useOneConnection)
useOneConnection - If true only one socket will be opened (default is false).openConnection(ConnectionInfo, ConnectionListener),
openConnection(ConnectionInfo, ConnectionListener, ConnectionPolicy),
openPollingConnection(ConnectionInfo, ConnectionListener),
openPollingConnection(ConnectionInfo, ConnectionListener, ConnectionPolicy),
subscribeTable(ExtendedTableInfo, ExtendedTableListener),
subscribeTable(SimpleTableInfo, SimpleTableListener),
subscribeTable(ExtendedTableInfo, HandyTableListener, boolean),
subscribeTable(SimpleTableInfo, HandyTableListener, boolean),
unsubscribeTable(SubscribedTableKey),
setBandwidthUnlimited(),
setMaxBandwidth(int),
sendMessage(String),
ConnectionPolicy.setBufferedStreamingHandled(boolean)public void useReusableItemUpdates(boolean useReusable)
SimpleItemUpdate and ExtendedItemUpdate
or ReusableSimpleItemUpdate and ReusableExtendedItemUpdate.
HandyTableListener is used, the setting has no effect,
as UpdateInfo objects are always returned; supplied objects
of this type are never reused by library code.
useReusable - Use reusable objects or do not (default is true).SimpleItemUpdate,
ExtendedItemUpdate,
ReusableSimpleItemUpdate,
ReusableExtendedItemUpdatepublic void setBufferMax(int bufferMax)
ConnectionListener.onBufferFull() is issued
and no more data is read from the connection until the buffer is empty.
bufferMax - The dimension of the client buffer (default is 10).
public void openPollingConnection(ConnectionInfo info,
ConnectionListener listener)
The Stream-sense feature is disabled, only poll connections will be used until a call to any openConnection is issued.
info - The connection parameters.listener - The connection listener which will receive state changes and errors
of the LSClient instance. If a previous instance of ConnectionListener was supplied
(via any openConnection/openPollingConnection call), that instance will
be overwritten and will not receives any updates.
java.lang.IllegalStateException - Thrown in single connection mode if no tables are
subscribed yet.ConnectionListener,
ConnectionInfo,
useSingleConnection(boolean)
public void openPollingConnection(ConnectionInfo info,
ConnectionListener listener,
ConnectionPolicy policy)
The Stream-sense feature is disabled, only poll connection will be used until a call to any openConnection is issued.
info - The connection parameters.listener - The connection listener which will receive state changes and errors
of the LSClient instance. If a previous instance of ConnectionListener was supplied
(via any openConnection/openPollingConnection call), that instance will
be overwritten and will not receives any updates.policy - The connection policies.
java.lang.IllegalStateException - Thrown in single connection mode if no tables are
subscribed yet.ConnectionListener,
ConnectionInfo,
ConnectionPolicy,
useSingleConnection(boolean)
public void openConnection(ConnectionInfo info,
ConnectionListener listener)
The Stream-sense feature is enabled, if the network infrastructure is not able to sustain streaming then the Client will switch to polling mode.
info - The connection parameters.listener - The connection listener which will receive state changes and errors
of the LSClient instance. If a previous instance of ConnectionListener was supplied
(via any openConnection/openPollingConnection call), that instance will
be overwritten and will not receives any updates.
java.lang.IllegalStateException - Thrown in single connection mode if no tables are
subscribed yet.ConnectionListener,
ConnectionInfo,
useSingleConnection(boolean)
public void openConnection(ConnectionInfo info,
ConnectionListener listener,
ConnectionPolicy policy)
The Stream-sense feature is enabled, if the network infrastructure is not able to sustain streaming then the Client will switch to polling mode.
info - The connection parameters.listener - The connection listener which will receive state changes and errors
of the LSClient instance. If a previous instance of ConnectionListener was supplied
(via any openConnection/openPollingConnection call), that instance will
be overwritten and will not receives any updates.policy - The connection policies.
java.lang.IllegalStateException - Thrown in single connection mode if no tables are
subscribed yet.ConnectionListener,
ConnectionInfo,
ConnectionPolicy,
useSingleConnection(boolean)public void closeConnection()
public SubscribedTableKey subscribeTable(ExtendedTableInfo info,
ExtendedTableListener tListener)
info - Contains the specification and request parameters
of the table to subscribe to.tListener - Receives notification of data updates and other messages
related to this subscription.
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.
java.lang.IllegalStateException - Thrown in single connection mode if the
client is already connected (or connecting) to Lightstreamer Server.
In single connection mode, subscription requests can only be issued
while the client is disconnected; the subscription requests are issued,
together with the connection request, upon the next call to
any openConnection/openPollingConnection.useSingleConnection(boolean)
public SubscribedTableKey subscribeTable(SimpleTableInfo info,
SimpleTableListener tListener)
info - Contains the specification and request parameters
of the table to subscribe to.tListener - Receives notification of data updates and other messages
related to this subscription.
java.lang.IllegalStateException - Thrown in single connection mode if the
client is already connected (or connecting) to Lightstreamer Server.
In single connection mode, subscription requests can only be issued
while the client is disconnected; the subscription requests are issued,
together with the connection request, upon the next call to
any openConnection/openPollingConnection.useSingleConnection(boolean)
public SubscribedTableKey subscribeTable(ExtendedTableInfo info,
HandyTableListener tListener,
boolean commandLogic)
info - Contains the specification and request parameters
of the table to subscribe to.tListener - Receives notification of data updates and other messages
related to this subscription.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.
java.lang.IllegalStateException - Thrown in single connection mode if the
client is already connected (or connecting) to Lightstreamer Server.
In single connection mode, subscription requests can only be issued
while the client is disconnected; the subscription requests are issued,
together with the connection request, upon the next call to
any openConnection/openPollingConnection.useSingleConnection(boolean)
public SubscribedTableKey subscribeTable(SimpleTableInfo info,
HandyTableListener tListener,
boolean commandLogic)
info - Contains the specification and request parameters
of the table to subscribe to.tListener - Receives notification of data updates and other messages
related to this subscription.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.
java.lang.IllegalStateException - Thrown in single connection mode if the
client is already connected (or connecting) to Lightstreamer Server.
In single connection mode, subscription requests can only be issued
while the client is disconnected; the subscription requests are issued,
together with the connection request, upon the next call to
any openConnection/openPollingConnection.useSingleConnection(boolean)public void unsubscribeTable(SubscribedTableKey key)
key - Handle to a table as returned by any subscribeTable call.
java.lang.IllegalStateException - Thrown in single connection mode if the
client is still connected (or connecting) to Lightstreamer Server.
In single connection mode, unsubscription requests can only be issued
while the client is disconnected; the remaining subscription requests
are then issued, together with the new connection request, upon the next
call to any openConnection/openPollingConnection.useSingleConnection(boolean)public boolean sendMessage(java.lang.String message)
ConnectionListener.onClientError(java.lang.String).
message - Any text string, to be interpreted by the Metadata Adapter. It should not be null.
java.lang.IllegalStateException - Thrown in any case in single connection mode.
In fact, sendMessage is not supported in single connection mode.useSingleConnection(boolean)public void setMaxBandwidth(int maxBandwidth)
setBandwidthUnlimited() method.
The limit can only be used in order to restrict the constraints
set by Lightstreamer Server Metadata Adapter.
Note that, if the session is already active, the request is sent
to the Server asynchronously with respect to the Client thread.
Any problem preventing the request from reaching the Server will be
notified through ConnectionListener.onClientError(java.lang.String).
Note: if single connection mode is used and the session is already
active, the new bandwidth limit will only apply to the next session.
The limit may be applied to current session only in case a new
rebind connection happens to be issued for the current session
(as in case of polling).
maxBandwidth - Bandwidth constraint, in Kbit/sec,
applied to the stream/poll connections.useSingleConnection(boolean)public void setBandwidthUnlimited()
setMaxBandwidth(int).
This setting does not override constraints set by Lightstreamer
Server Metadata Adapter.
See setMaxBandwidth(int) for further notes.
public java.lang.String getStatus()
public java.lang.String toString()
toString in class java.lang.Objectpublic static void closeApp()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||