Options
All
  • Public
  • Public/Protected
  • All
Menu

BridgeRpc is an Bridge RPC client can connect to Bridge RPC server and register methods and emit a request or a notification.

Hierarchy

  • BridgeRpc

Index

Constructors

constructor

  • Initialize an BridgeRpc object, start receiving/sending after called connect. Suggest you register the handling methods before you call connect.

    Parameters

    • url: string

      Url of the server to be connected.

    Returns BridgeRpc

Properties

Protected _rawSocket

_rawSocket: WebSocket | null = null

Protected callbacks

Protected handlers

Protected notificationHandlers

notificationHandlers: NotificationHandlerDictionary

Protected url

url: string

Accessors

rawSocket

rawSocket:

Get [[WebSocket]] object maintained by BridgeRpc object. BE CAREFUL to access this getter.

Methods

close

  • close(code: number, reason: string): void
  • Close the connection.

    Parameters

    • code: number

      A numeric value indicating the status code explaining why the connection is being closed. If this parameter is not specified, a default value of 1005 is assumed. See the list of status codes of CloseEvent for permitted values.

    • reason: string

      A human-readable string explaining why the connection is closing. This string must be no longer than 123 bytes of UTF-8 text (not characters).

    Returns void

connect

  • connect(): void
  • Connect to the server. Suggest you register the handling methods before you call connect.

    Returns void

notify

  • notify(method: string, data: any): void
  • Call remote method without response.

    Parameters

    • method: string

      The method name to be called.

    • data: any

      Parameters to be sent.

    Returns void

onConnect

  • onConnect(connected: function): void
  • An event listener to be called when the server is connected.

    Parameters

    • connected: function

      The event listener.

        • (): void
        • Returns void

    Returns void

Protected onMessage

  • onMessage(event: any): void
  • An event listener for [[WebSocket]] onmessage to handle BridgeRpc message.

    Parameters

    • event: any

      Event object from WebSocket.onmessage

    Returns void

onNotify

  • An event listener with method name to be called when received a notification.

    Parameters

    • method: string

      The name of the method will be registered.

    • handler: RpcNotificationHandler

      The event listener, no return value.

    Returns void

onRequest

  • onRequest(method: string, handler: RpcHandler): void
  • An event listener with method name to be called when received a request.

    Parameters

    • method: string

      The name of the method will be registered.

    • handler: RpcHandler

      The event listener, must returned a RpcResponse.

    Returns void

request

  • request(method: string, data: any, timeoutMilliSeconds?: number): Promise<RpcResponse>
  • Call remote method.

    Parameters

    • method: string

      The method name to be called.

    • data: any

      Parameters to be sent.

    • Default value timeoutMilliSeconds: number = 5000

      Timeout of request operation, unit is millisecond.

    Returns Promise<RpcResponse>

Static Protected internalErrorResponse

Static Protected methodNotFoundResponse

Static Protected randomString

  • randomString(): string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc