rpclibrary › Globals › “Frontend” › RPCSocket
A websocket-on-steroids with built-in RPC capabilities
+ 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
• port: number
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
▸ 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(): void
Implementation of Socket
Defined in Frontend.ts:68
Closes the socket. It may attempt to reconnect.
Returns: void
▸ connect(): Promise‹void›
Defined in Frontend.ts:93
Connects to the server and attaches available RPCs to this object
Returns: Promise‹void›
▸ destroy(): void
Implementation of Socket
Defined in Frontend.ts:61
Destroys the socket
Returns: void
▸ 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(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(): Promise‹any›
Defined in Frontend.ts:117
Get a list of available RPCs from the server
Returns: Promise‹any›
▸ 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(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