Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Services Adapter to Core Protocol

Thomas O'Connor edited this page Mar 6, 2018 · 2 revisions

Basic Adapter Envelope to Core

{
    action: string,
    messageId: number, // automatically set by adapter
    payload: any // generally an object with options/parameters (undefined if not mentioned in calls below)
}

Call to register service: fin.desktop.Service.register()

On the ack from core, return channel for the service to send service messages (see javascript-adapter)

{
    action: 'register-service',
    ...
}

All other calls have the action: send-service-message

Call from client to connect to service: fin.desktop.Service.connect(options)

On the ack from core, return channel for the client to send service messages (see javascript-adapter)

{
    action: 'send-service-message',
    payload: {
        connectAction: true,
        wait?: bool, // options.wait (optional - default to true in adapter if undefined)
        uuid: string, // options.uuid (uuid of service - mandatory)
        payload?: any // options.payload
    }
    ...
}

Call from client/service to be handled by service/client after connection: fin.desktop.Service.dispatch(topic: string, payload: any, ack?: cb, nack?: cb)

{
    action: 'send-service-message',
    payload: {
        action: string, // topic argument
        uuid: string, // uuid of client or service
        name: string, // name of client (necessary to send service msg to client)
        payload: object // payload argument
    }
    ...
}

Incoming service message to adapter from client/service via core (above dispatch call)

{
    action: 'process-service-action',
    correlationId: number,
    payload: {
        ackToSender, // object to send back to core to ack to sender (see below)
        action: string, // action dispatched by the sender (topic argument in dispatch)
        serviceIdentity : Identity, // {uuid: string} - always service Identity no matter the sender
        payload, // sender defined payload / arguments for action function
        senderIdentity: Identity // {uuid: string, name: string}
    }
}

Ack back to client/service via the core from client/service (ack to above dispatch call)

This shape is sent in ackToSender object in the incoming process-service-action message (inside the payload above).

{
    action: 'service-ack',
    correlationId: number,
    payload: {
        correlationId: number,  // provided by core - used to store & retrieve ack from map
        destinationToken: identity,  // provided by core - identity of original sender
        // If it is a connection request, uuid/name of service placed on payload in ackToSender automatically
        payload: {
            uuid?: string,
            name?: string,
            result: any // adapter to add any information to ack back to original sender should be put here 
    },
    success: true // change to false to nack
    reason?: string // add a reason string here for nack (not passed in original ackToSender)
}