You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_frontend_.rpcsocket.md 5.6KB

rpclibraryGlobals“Frontend”RPCSocket

Class: RPCSocket

A websocket-on-steroids with built-in RPC capabilities

Hierarchy

  • RPCSocket

Implements

Index

Constructors

Properties

Methods

Constructors

constructor

+ new RPCSocket(port: number, server: string, tls: boolean): RPCSocket

Defined in Frontend.ts:20

Parameters:

Name Type Default Description
port number - Port to connect to
server string - Server address
tls boolean false @default false use TLS

Returns: RPCSocket

Properties

port

port: number

Implementation of Socket.port

Defined in Frontend.ts:28

Port to connect to


Private server

server: string

Defined in Frontend.ts:28

Server address


Private socket

socket: Socket

Defined in Frontend.ts:20


Private tls

tls: boolean

Defined in Frontend.ts:28

@default false use TLS

Methods

call

call(rpcname: T.Name, …args: T.Any[]): Promise‹T.Any›

Defined in Frontend.ts:77

Trigger a hooked handler on the server

Parameters:

Name Type Description
rpcname T.Name The function to call
...args T.Any[] other arguments

Returns: Promise‹T.Any›


Private callGenerator

callGenerator(fnName: T.Name, fnArgs: T.Arg[]): T.AsyncFunction

Defined in Frontend.ts:126

Utility AsyncFunction generator

Parameters:

Name Type Description
fnName T.Name The function name
fnArgs T.Arg[] A string-list of parameters

Returns: T.AsyncFunction


close

close(): void

Implementation of Socket

Defined in Frontend.ts:68

Closes the socket. It may attempt to reconnect.

Returns: void


connect

connect(): Promise‹void›

Defined in Frontend.ts:93

Connects to the server and attaches available RPCs to this object

Returns: Promise‹void›


destroy

destroy(): void

Implementation of Socket

Defined in Frontend.ts:61

Destroys the socket

Returns: void


fire

fire(rpcname: T.Name, …args: T.Any[]): Promise‹void›

Defined in Frontend.ts:86

An alternative to call that does not wait for confirmation and doesn’t return a value.

Parameters:

Name Type Description
rpcname T.Name The function to call
...args T.Any[] other arguments

Returns: Promise‹void›


hook

hook(name: T.Name, handler: function): Socket

Defined in Frontend.ts:37

Hooks a handler to a function name. Use call to trigger it.

Parameters:

name: T.Name

The function name to listen on

handler: function

The handler to attach

▸ (…args: any[]): any | Promise‹any›

Parameters:

Name Type
...args any[]

Returns: Socket


Private hookGenerator

hookGenerator(fnName: T.Name, fnArgs: T.Arg[]): T.HookFunction

Defined in Frontend.ts:137

Utility HookFunction generator

Parameters:

Name Type Description
fnName T.Name The function name
fnArgs T.Arg[] A string-list of parameters

Returns: T.HookFunction


info

info(): Promise‹any›

Defined in Frontend.ts:117

Get a list of available RPCs from the server

Returns: Promise‹any›


on

on(type: “error” | “close”, f: function): Socket

Defined in Frontend.ts:54

Attach a listener to error or close events

Parameters:

type: “error” | “close”

‘error’ or ‘close’

f: function

The listener to attach

▸ (e?: any): void

Parameters:

Name Type
e? any

Returns: Socket


unhook

unhook(name: T.Name): Socket

Defined in Frontend.ts:45

Removes a hook listener by name.

Parameters:

Name Type Description
name T.Name The function name

Returns: Socket