Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ServiceAdapter

Adaptor to bridge v4-stack components and command services.

Hierarchy

  • ServiceAdapter

Index

Constructors

constructor

  • Create a new ServiceAdapter instance

    Parameters

    Returns ServiceAdapter

Properties

Private internalSession

internalSession: InternalSession

The internal session this adapter is bound to

Private listeners

listeners: object

Listeners that have bee registered for each command service

Type declaration

Private sender

The function to enqueue messages

Methods

addService

  • addService<Request, Response>(definition: ServiceDefinition<Request, Response>, service: Service<Request, Response>): void
  • Add a service to the adapter, in order to receive requests from the server.

    Type parameters

    • Request

    • Response

    Parameters

    • definition: ServiceDefinition<Request, Response>

      the service definition

    • service: Service<Request, Response>

      the service implementation

    Returns void

Private handleError

  • Handle an error coming back from the server

    Parameters

    Returns void

Private handleRequest

  • Handle an incoming request

    Parameters

    Returns void

Private handleResponse

  • Handle a response coming back from the server

    Parameters

    Returns void

isServiceRegistered

  • isServiceRegistered(serviceId: number): boolean
  • Checks whether a service is already registered.

    Parameters

    • serviceId: number

    Returns boolean

onMessage

  • Callback function to handle inbound command messages to be routed to appropriate handlers.

    throws

    an Error if parsed CommandHeader is invalid

    Parameters

    • modes: number

      the service message mode.

    • data: BufferInputStream

      the input stream to read from.

    Returns void

sendError

  • Send an error command message to the server for a given service.

    Parameters

    Returns void

sendRequest

  • Send a request command message to the server for a given service.

    Parameters

    • header: CommandHeader

      the header encapsulating the message's context.

    • command: any

      the command to send.

    • serialiser: Serialiser<any>

      the serialiser for the command object.

    Returns void

sendResponse

  • Send a response command message to the server for a given service.

    Parameters

    • header: CommandHeader

      the header encapsulating the message's context.

    • command: any

      the command to send.

    • serialiser: Serialiser<any>

      the serialiser for the command object.

    Returns void