Where to register service and request handlers in JS client?

  • We've been trying out the JS client on our team and our services register correctly when we put the calls to DxlClient.registerServiceAsync() in the prototype function for Application.onRegisterServices.

  • clara_kt is correct, service registration should be handled in by creating a prototype version of Application.prototype.onRegisterServices in your application.


    There are several callbacks you can expect the Application to execute:


    Application.prototype.onLoadConfiguration Executed after the Application has parsed the configuration file but before creating/populating the DxlClientConfig object that will be used to connect to the fabric.
    Application.prototype.onRegisterEventHandlers Executed after the DXL Client has connected to the fabric. Used for registering event handler callbacks for the service.
    Application.prototype.onRegisterServices Executed after the DXL Client has connected to the fabric, after onRegisterEventHandlers. Used for creating and registering services.
    Application.prototype.onDxlConnect
    Executed after the DXL Client has connected to the fabric, after onRegisterServices. Used for any behavior you wish to execute immediately after the client has connected but before running the Application.
    Application.prototype.onRun Executed after the Application has started running (after loading configuration, and connecting to the fabric).


    Here is an example a prototype function implementation for Application.prototype.onRegisterServices: