public interface ConnectionProvider
LSClient.setConnectionProvider(ConnectionProvider)
so that it will be used in place of the default one.Modifier and Type | Field and Description |
---|---|
static int |
TYPE_HTTP
Constant used to specify that a HttpConnection is expected.
|
static int |
TYPE_SOCKET
Constant used to specify that a SocketConnection is expected.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
Clone method used internally to spread the provider inside the various parts of the library.
|
javax.microedition.io.Connection |
getNextConnection(java.lang.String url,
boolean secure)
Provider method used to obtain a new Connection instance to be used to connect to Lightstreamer server.
|
boolean |
hasConnections()
Test method that returns true if this provider is still able to provide a new type of Connection in response of
a
getNextConnection(String, boolean) call for a certain type parameter value. |
void |
rebuild()
Method used to reset the current instance.
|
void |
setType(int type)
Defines the type of ConnectionProvider.
|
void |
wasSuccessful()
Called after the
getNextConnection(String, boolean) method to inform the ConnectionProvider that the last given Connection was successfully
used by the library. |
static final int TYPE_HTTP
static final int TYPE_SOCKET
void setType(int type)
TYPE_HTTP
ConnectionProvider must provide instances of
HttpConnection while a TYPE_SOCKET
ConnectionProvider must provide instances of SocketConnection.type
- Flag specifying the type of the expected Connection,
TYPE_HTTP
for HttpConnection or TYPE_SOCKET
for SocketConnection.void rebuild()
getNextConnection(String, boolean)
calls using the same
type parameter value.void wasSuccessful()
getNextConnection(String, boolean)
method to inform the ConnectionProvider that the last given Connection was successfully
used by the library. If rebuild()
is called two times without this method being called, then the library wasn't able
to connect to the server at all with the given Connection(s). This may happen if there is no network availability or,
if the Connection was constructed in a wrong way in respect with the current environment.
If the active ConnectionProvider is substituted while the library is connected/connecting this method may be called before any
getNextConnection call. In that case it has to be ignored.boolean hasConnections()
getNextConnection(String, boolean)
call for a certain type parameter value.javax.microedition.io.Connection getNextConnection(java.lang.String url, boolean secure) throws java.io.IOException
url
- The url to be opened.secure
- If true a new secure connection is needed. Info related to the secure/non-secure nature
of the connection can also be extracted from the url parameter.java.io.IOException
- If some kind of I/O error occurs.java.lang.Object clone()