Options
All
  • Public
  • Public/Protected
  • All
Menu

Class LibTop

Handles application-level calls and packages them into efficient opaque messages.

Hierarchy

  • LibTop

Index

Constructors

constructor

  • new LibTop(options: LibTopOptions): LibTop

Properties

Private events

events: Buffer[]

Private eventsOrdered

eventsOrdered: Buffer[]

Readonly idCreator

idCreator: default

incObj

incObj: Record<string, any>

outObj

outObj: Record<string, any>

Private outObjSent

outObjSent: Record<string, any>

Readonly requests

requests: Map<number, FnCall>

Readonly requestsOrdered

requestsOrdered: Map<number, FnCall>

Readonly responses

responses: Map<number, FnCall>

Private transcoder

transcoder: Transcoder

Methods

callFn

  • callFn(method: string, args?: Buffer): number
  • Calls a function that will be processed as soon as it is received.

    Parameters

    • method: string

      Name of method to call

    • Optional args: Buffer

      Optional arguments

    Returns number

    Id number of this request

Private callFnInternal

  • callFnInternal(requestsMap: Map<number, FnCall>, method: string, args?: Buffer): number
  • Parameters

    • requestsMap: Map<number, FnCall>
    • method: string
    • Optional args: Buffer

    Returns number

callFnOrdered

  • callFnOrdered(method: string, args?: Buffer): number
  • Calls a function that will be processed in order with other messages.

    Parameters

    • method: string

      Name of method to call

    • Optional args: Buffer

      Optional arguments

    Returns number

    Id number of this request

getLibState

  • getLibState(): string
  • Get the serialized version of this object. Used to store the state and to later restore it using LibTopOptions.restoreState.

    Returns string

Private receiveFnCalls

  • receiveFnCalls(requests: Record<string, RpcReqObj>): FnCall[]
  • Parameters

    • requests: Record<string, RpcReqObj>

    Returns FnCall[]

receiveFnResults

  • receiveFnResults(results: Record<string, RpcResObj>): FnCall[]
  • Parameters

    • results: Record<string, RpcResObj>

    Returns FnCall[]

receiveMessage

  • Accepts and processes a message coming from the other side.

    Parameters

    • msgs: Buffer | ReceivedMessage | ReceivedMessage[]

      Array of ReceivedMessage objects or a single ReceivedMessage object or a Buffer that will be treated as a single complete full message.

    Returns ReceiveMessageObject

    Object containing the processed message

Private receiveObjDelete

  • receiveObjDelete(obj: Record<string, any>): void

Private receiveObjSync

  • receiveObjSync(obj: Record<string, any>): void

send

  • send(autoConfirmChanges?: boolean): [Buffer, () => void]
  • Emit message with all unsent data

    function

    send

    Parameters

    • autoConfirmChanges: boolean = true

    Returns [Buffer, () => void]

sendEvent

  • sendEvent(event: Buffer): void
  • Send event without ordering

    function

    sendEvent

    Parameters

    • event: Buffer

      Event to send

    Returns void

sendEventOrdered

  • sendEventOrdered(event: Buffer): void
  • Send event with guaranteed ordering

    function

    sendEvent

    Parameters

    • event: Buffer

      Event to send

    Returns void

sendFnCallResponse

  • sendFnCallResponse(id: number, returns?: Buffer, isError?: boolean): void
  • Sends a response to the function call associated with the given id.

    Parameters

    • id: number

      Id number of the request

    • returns: Buffer = null

      Optional response Buffer

    • isError: boolean = false

      Set to true to signify an error, ignore otherwise.

    Returns void

Generated using TypeDoc