IBM Worklight v5.0.5 > API reference > IBM Worklight client-side API > JavaScript client-side API

WL.Client.connect

Establish a connection to the WL server. Call this method before calling any other WL.Client method that communicates with the WL server.

Parameter Description
options Optional. A JSON block with the following additional properties:

onSuccess Callback function invoked when the connection to the WL server is established
onFailure Callback function invoked when the connection to the WL server is unsuccessful. The callback receives one parameter of type WL.FailResponse, which might be null if connect is called while a previous call to connect has not yet returned.
timeout Integer. Number of milliseconds to wait for the server response before failing with a request timeout.


Connectivity-related JavaScript Events

The IBM Worklight runtime framework fires two events, to which you can listen to capture changes in connectivity. The events are fired only on change of connectivity state.

WL.Events.WORKLIGHT_IS_CONNECTED fired when the application connects to the WL server
WL.Events.WORKLIGHT_IS_DISCONNECTED fired when loss of connectivity to WL server is detected

Example...


Parent JavaScript client-side API