Class finesse.clientservices.ClientServices
Allow clients to make Finesse API requests and consume Finesse events by
calling a set of exposed functions. The Services layer will do the dirty
work of establishing a shared BOSH connection (for designated Master
modules), consuming events for client subscriptions, and constructing API
requests.
Defined in: finesse.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
init(config)
Initiates the Client Services with the specified config parameters.
|
|
registerOnConnectHandler(handler)
Add a callback to be invoked when all of the following conditions are met:
|
|
registerOnDisconnectHandler(handler)
Add a callback to be invoked when any of the following occurs:
|
Method Detail
init(config)
Initiates the Client Services with the specified config parameters.
Enabling the Client Services as Master will trigger the establishment
of a BOSH event connection.
finesse.clientservices.ClientServices.init(finesse.gadget.Config);
- Parameters:
- {finesse.gadget.Config} config
- Configuration object containing properties used for making REST requests:
- host: The Finesse server IP/host as reachable from the browser
- restHost: The Finesse API IP/host as reachable from the gadget container
- id: The ID of the user. This is an optional param as long as the appropriate authorization string is provided, otherwise it is required.
- password: The password belonging to the user. This is an optional param as long as the appropriate authorization string is provided, otherwise it is required.
- authorization: The base64 encoded "id:password" authentication string. This param is provided to allow the ability to hide the password param. If provided, the id and the password extracted from this string will be used over the config.id and config.password.
- Throws:
- {Error}
- If required constructor parameter is missing.
registerOnConnectHandler(handler)
Add a callback to be invoked when all of the following conditions are met:
- When Finesse goes IN_SERVICE
- The BOSH connection is established
- The Finesse user presence becomes available
finesse.clientservices.ClientServices.registerOnConnectHandler(gadget.myCallback);
- Parameters:
- {Function} handler
- An empty param function to be invoked on connect. Only one handler can be registered at a time. Handlers already registered will be overwritten.
registerOnDisconnectHandler(handler)
Add a callback to be invoked when any of the following occurs:
- Finesse is no longer IN_SERVICE
- The BOSH connection is lost
- The presence of the Finesse user is no longer available
finesse.clientservices.ClientServices.registerOnDisconnectHandler(gadget.myCallback);
- Parameters:
- {Function} handler
- An empty param function to be invoked on disconnected. Only one handler can be registered at a time. Handlers already registered will be overwritten.