interface ClientListener
package com.lightstreamer.client
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
ClientListener
s, SubscriptionListener
s and ClientMessageListener
s will be dispatched by the
same thread.
Methods
onListenEnd(client:LightstreamerClient):Void
Event handler that receives a notification when the ClientListener instance is removed from a LightstreamerClient
through LightstreamerClient.removeListener(ClientListener)
. This is the last event to be fired on the listener.
Parameters:
client | the LightstreamerClient this instance was removed from. |
---|
onListenStart(client:LightstreamerClient):Void
Event handler that receives a notification when the ClientListener instance is added to a LightstreamerClient
through LightstreamerClient.addListener(ClientListener)
. This is the first event to be fired on the listener.
Parameters:
client | the LightstreamerClient this instance was added to. |
---|
onServerError(errorCode:Int, errorMessage:String):Void
Event handler that is called when the Server notifies a refusal on the client attempt to open
a new connection or the interruption of a streaming connection.
In both cases, the this.onStatusChange
event handler has already been invoked
with a "DISCONNECTED" status and no recovery attempt has been performed.
By setting a custom handler, however, it is possible to override this and perform custom recovery actions.
Parameters:
errorCode | The error code. It can be one of the following:
|
---|---|
errorMessage | The description of the error as sent by the Server. |
See also:
this.onStatusChange(String)
ConnectionDetails.setAdapterSet(String)
onStatusChange(status:String):Void
Event handler that receives a notification each time the LightstreamerClient status has changed. The status changes
may be originated either by custom actions (e.g. by calling LightstreamerClient.disconnect
) or by internal
actions.
The normal cases are the following:
- After issuing connect() when the current status is "DISCONNECTED*", the client will switch to "CONNECTING"
first and to "CONNECTED:STREAM-SENSING" as soon as the pre-flight request receives its answer.
As soon as the new session is established, it will switch to "CONNECTED:WS-STREAMING" if the environment permits WebSockets; otherwise it will switch to "CONNECTED:HTTP-STREAMING" if the environment permits streaming or to "CONNECTED:HTTP-POLLING" as a last resort. - On the other hand, after issuing connect when the status is already "CONNECTED:*" a switch to "CONNECTING" is usually not needed and the current session is kept.
- After issuing
LightstreamerClient.disconnect
, the status will switch to "DISCONNECTED". - In case of a server connection refusal, the status may switch from "CONNECTING" directly to "DISCONNECTED".
After that, the
this.onServerError
event handler will be invoked.
- In case of Server unavailability during streaming, the status may switch from "CONNECTED:*-STREAMING"
to "STALLED" (see
ConnectionOptions.setStalledTimeout(long)
). If the unavailability ceases, the status will switch back to "CONNECTED:*-STREAMING"; otherwise, if the unavailability persists (seeConnectionOptions.setReconnectTimeout(long)
), the status will switch to "DISCONNECTED:TRYING-RECOVERY" and eventually to "CONNECTED:*-STREAMING". - In case the connection or the whole session is forcibly closed by the Server, the status may switch
from "CONNECTED:*-STREAMING" or "CONNECTED:*-POLLING" directly to "DISCONNECTED". After that,
the
this.onServerError
event handler will be invoked. - Depending on the setting in
ConnectionOptions.setSlowingEnabled(boolean)
, in case of slow update processing, the status may switch from "CONNECTED:WS-STREAMING" to "CONNECTED:WS-POLLING" or from "CONNECTED:HTTP-STREAMING" to "CONNECTED:HTTP-POLLING". - If the status is "CONNECTED:*-POLLING" and any problem during an intermediate poll occurs, the status may switch to "CONNECTING" and eventually to "CONNECTED:*-POLLING". The same may hold for the "CONNECTED:*-STREAMING" case, when a rebind is needed.
- In case a forced transport was set through
ConnectionOptions.setForcedTransport(String)
, only the related final status or statuses are possible. - In case of connection problems, the status may switch from any value
to "DISCONNECTED:WILL-RETRY" (see
ConnectionOptions.setRetryDelay(long)
), then to "CONNECTING" and a new attempt will start. However, in most cases, the client will try to recover the current session; hence, the "DISCONNECTED:TRYING-RECOVERY" status will be entered and the recovery attempt will start. - In case of connection problems during a recovery attempt, the status may stay in "DISCONNECTED:TRYING-RECOVERY" for long time, while further attempts are made. If the recovery is no longer possible, the current session will be abandoned and the status will switch to "DISCONNECTED:WILL-RETRY" before the next attempts.
LightstreamerClient.connect
and LightstreamerClient.disconnect
, as any other method, can
be issued directly from within a handler.Parameters:
status | The new status. It can be one of the following values:
|
---|
See also:
onPropertyChange(property:String):Void
Event handler that receives a notification each time the value of a property of
LightstreamerClient.connectionDetails
or LightstreamerClient.connectionOptions
is changed.
Properties of these objects can be modified by direct calls to them or
by server sent events.
Parameters:
property | the name of the changed property.
|
---|
See also: