Subscription Support

Finesse JavaScript objects support subscription to the XMPP events. These events are the notifications generated by the Openfire server and pushed to the desktop as XMPP events. Any JavaScript object that supports subscription is automatically hooked up for listening to XMPP events when it is initialized.

Note

This subscription is not a Notification subscription but a desktop level subscription to receive the events generated by the OpenAjax hub.

For example, the User API supports the subscription model and the User functions as stated in the below example.

Example for User Functions
Code Snippet
Copyvar _user = new finesse.restservices.User({
    id: '1001001',
    onLoad: function(user){
        // Do something on the successful fetch(GET) of user object
    },
    onChange: function(user){
        // Do something on the successful update(PUT) of object
        // can do user.getState() or user.getTeamName()
    },
    onAdd: function(user){},
    onDelete: function(user){},
    onError: function(err){
        // Something went wrong while fetching user data, show an error dialog to the user may be.
    }
});

These handlers can handle the REST response and the XMPP events. For example, when the state change for a signed-in User is triggered by another agent (that is, Supervisor), the client or desktop receives a User update XMPP event on the node "/finesse/api/User/1001001".

Payload with Updated User State Details

Code Snippet
Copy<Update>
  <data>
    <user>
      <dialogs>/finesse/api/User/1001001/Dialogs</dialogs>
      <extension>1001001</extension>
      <firstName>AGENT</firstName>
      <lastName>1001001</lastName>
      <loginId>1001001</loginId>
      <loginName>agent444agent444agent444agent444</loginName>
      <mediaType>1</mediaType>
      <pendingState></pendingState>
      <roles>
        <role>Agent</role>
      </roles>
      <settings>
        <wrapUpOnIncoming>OPTIONAL</wrapUpOnIncoming>
        <wrapUpOnOutgoing>NOT_ALLOWED</wrapUpOnOutgoing>
      </settings>
      <state>READY</state>
      <stateChangeTime>2020-03-13T05:45:26.827Z</stateChangeTime>
      <teamId>5000</teamId>
      <teamName>FunctionalAgents</teamName>
      <uri>/finesse/api/User/1001001</uri>
      <wrapUpTimer>30</wrapUpTimer>
    </user>
  </data>
  <event>PUT</event>
  <requestId>2a7f6cd3-bd26-4e46-a8ea-429cba8d9ff7</requestId>
  <source>/finesse/api/User/1001004</source>
</Update>

The XMPP events are handled, and the same onChange handler provided by you is invoked by the Finesse JavaScript library.