doc
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
# Class: RPCServer <**SubResType**>
|
||||
|
||||
A Websocket-server-on-steroids with built-in RPC capabilities
|
||||
|
||||
## Type parameters
|
||||
|
||||
▪ **SubResType**
|
||||
@@ -41,17 +43,19 @@
|
||||
|
||||
### constructor
|
||||
|
||||
\+ **new RPCServer**(`port`: number, `exporters`: [Exporter](../interfaces/_interfaces_.exporter.md)‹SubResType›[], `conf`: T.SocketConf): *[RPCServer](_backend_.rpcserver.md)*
|
||||
\+ **new RPCServer**(`port`: number, `exporters`: [RPCExporter](../interfaces/_interfaces_.rpcexporter.md)‹SubResType›[], `conf`: T.SocketConf): *[RPCServer](_backend_.rpcserver.md)*
|
||||
|
||||
Defined in Backend.ts:19
|
||||
Defined in Backend.ts:22
|
||||
|
||||
**`throws`** On RPC with no name
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`port` | number | - |
|
||||
`exporters` | [Exporter](../interfaces/_interfaces_.exporter.md)‹SubResType›[] | [] |
|
||||
`conf` | T.SocketConf | {} |
|
||||
Name | Type | Default | Description |
|
||||
------ | ------ | ------ | ------ |
|
||||
`port` | number | - | The port to listen on |
|
||||
`exporters` | [RPCExporter](../interfaces/_interfaces_.rpcexporter.md)‹SubResType›[] | [] | A list of [RPCExporter](../interfaces/_interfaces_.rpcexporter.md) to publish |
|
||||
`conf` | T.SocketConf | {} | A [SocketConf](../modules/_types_.md#socketconf) object with optional settings |
|
||||
|
||||
**Returns:** *[RPCServer](_backend_.rpcserver.md)*
|
||||
|
||||
@@ -61,7 +65,7 @@ Name | Type | Default |
|
||||
|
||||
• **closeHandler**: *T.CloseHandler*
|
||||
|
||||
Defined in Backend.ts:17
|
||||
Defined in Backend.ts:20
|
||||
|
||||
___
|
||||
|
||||
@@ -69,7 +73,7 @@ ___
|
||||
|
||||
• **connectionHandler**: *T.ConnectionHandler*
|
||||
|
||||
Defined in Backend.ts:19
|
||||
Defined in Backend.ts:22
|
||||
|
||||
___
|
||||
|
||||
@@ -77,15 +81,17 @@ ___
|
||||
|
||||
• **errorHandler**: *T.ErrorHandler*
|
||||
|
||||
Defined in Backend.ts:18
|
||||
Defined in Backend.ts:21
|
||||
|
||||
___
|
||||
|
||||
### `Private` exporters
|
||||
|
||||
• **exporters**: *[Exporter](../interfaces/_interfaces_.exporter.md)‹SubResType›[]*
|
||||
• **exporters**: *[RPCExporter](../interfaces/_interfaces_.rpcexporter.md)‹SubResType›[]*
|
||||
|
||||
Defined in Backend.ts:23
|
||||
Defined in Backend.ts:32
|
||||
|
||||
A list of [RPCExporter](../interfaces/_interfaces_.rpcexporter.md) to publish
|
||||
|
||||
___
|
||||
|
||||
@@ -93,7 +99,7 @@ ___
|
||||
|
||||
• **io**: *any* = bsock.createServer()
|
||||
|
||||
Defined in Backend.ts:15
|
||||
Defined in Backend.ts:18
|
||||
|
||||
___
|
||||
|
||||
@@ -101,7 +107,9 @@ ___
|
||||
|
||||
• **port**: *number*
|
||||
|
||||
Defined in Backend.ts:22
|
||||
Defined in Backend.ts:31
|
||||
|
||||
The port to listen on
|
||||
|
||||
___
|
||||
|
||||
@@ -109,7 +117,7 @@ ___
|
||||
|
||||
• **visibility**: *T.Visibility*
|
||||
|
||||
Defined in Backend.ts:16
|
||||
Defined in Backend.ts:19
|
||||
|
||||
___
|
||||
|
||||
@@ -117,7 +125,7 @@ ___
|
||||
|
||||
• **ws**: *Server* = http.createServer()
|
||||
|
||||
Defined in Backend.ts:14
|
||||
Defined in Backend.ts:17
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -127,7 +135,7 @@ Defined in Backend.ts:14
|
||||
|
||||
*Implementation of [Destroyable](../interfaces/_interfaces_.destroyable.md)*
|
||||
|
||||
Defined in Backend.ts:80
|
||||
Defined in Backend.ts:89
|
||||
|
||||
**Returns:** *Promise‹void›*
|
||||
|
||||
@@ -137,7 +145,7 @@ ___
|
||||
|
||||
▸ **initRPCs**(`socket`: [Socket](../interfaces/_interfaces_.socket.md)): *void*
|
||||
|
||||
Defined in Backend.ts:73
|
||||
Defined in Backend.ts:82
|
||||
|
||||
**Parameters:**
|
||||
|
||||
@@ -153,6 +161,6 @@ ___
|
||||
|
||||
▸ **startWebsocket**(): *void*
|
||||
|
||||
Defined in Backend.ts:57
|
||||
Defined in Backend.ts:66
|
||||
|
||||
**Returns:** *void*
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
# Class: RPCSocket
|
||||
|
||||
A websocket-on-steroids with built-in RPC capabilities
|
||||
|
||||
## Hierarchy
|
||||
|
||||
* **RPCSocket**
|
||||
@@ -43,15 +45,15 @@
|
||||
|
||||
\+ **new RPCSocket**(`port`: number, `server`: string, `tls`: boolean): *[RPCSocket](_frontend_.rpcsocket.md)*
|
||||
|
||||
Defined in Frontend.ts:15
|
||||
Defined in Frontend.ts:20
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type | Default |
|
||||
------ | ------ | ------ |
|
||||
`port` | number | - |
|
||||
`server` | string | - |
|
||||
`tls` | boolean | false |
|
||||
Name | Type | Default | Description |
|
||||
------ | ------ | ------ | ------ |
|
||||
`port` | number | - | Port to connect to |
|
||||
`server` | string | - | Server address |
|
||||
`tls` | boolean | false | @default false use TLS |
|
||||
|
||||
**Returns:** *[RPCSocket](_frontend_.rpcsocket.md)*
|
||||
|
||||
@@ -63,7 +65,9 @@ Name | Type | Default |
|
||||
|
||||
*Implementation of [Socket](../interfaces/_interfaces_.socket.md).[port](../interfaces/_interfaces_.socket.md#port)*
|
||||
|
||||
Defined in Frontend.ts:16
|
||||
Defined in Frontend.ts:28
|
||||
|
||||
Port to connect to
|
||||
|
||||
___
|
||||
|
||||
@@ -71,7 +75,9 @@ ___
|
||||
|
||||
• **server**: *string*
|
||||
|
||||
Defined in Frontend.ts:16
|
||||
Defined in Frontend.ts:28
|
||||
|
||||
Server address
|
||||
|
||||
___
|
||||
|
||||
@@ -79,7 +85,7 @@ ___
|
||||
|
||||
• **socket**: *[Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Defined in Frontend.ts:15
|
||||
Defined in Frontend.ts:20
|
||||
|
||||
___
|
||||
|
||||
@@ -87,7 +93,9 @@ ___
|
||||
|
||||
• **tls**: *boolean*
|
||||
|
||||
Defined in Frontend.ts:16
|
||||
Defined in Frontend.ts:28
|
||||
|
||||
@default false use TLS
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -95,14 +103,16 @@ Defined in Frontend.ts:16
|
||||
|
||||
▸ **call**(`rpcname`: T.Name, ...`args`: T.Any[]): *Promise‹T.Any›*
|
||||
|
||||
Defined in Frontend.ts:40
|
||||
Defined in Frontend.ts:77
|
||||
|
||||
Trigger a hooked handler on the server
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`rpcname` | T.Name |
|
||||
`...args` | T.Any[] |
|
||||
Name | Type | Description |
|
||||
------ | ------ | ------ |
|
||||
`rpcname` | T.Name | The function to call |
|
||||
`...args` | T.Any[] | other arguments |
|
||||
|
||||
**Returns:** *Promise‹T.Any›*
|
||||
|
||||
@@ -112,14 +122,16 @@ ___
|
||||
|
||||
▸ **callGenerator**(`fnName`: T.Name, `fnArgs`: T.Arg[]): *T.AsyncFunction*
|
||||
|
||||
Defined in Frontend.ts:73
|
||||
Defined in Frontend.ts:126
|
||||
|
||||
Utility [AsyncFunction](../modules/_types_.md#asyncfunction) generator
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`fnName` | T.Name |
|
||||
`fnArgs` | T.Arg[] |
|
||||
Name | Type | Description |
|
||||
------ | ------ | ------ |
|
||||
`fnName` | T.Name | The function name |
|
||||
`fnArgs` | T.Arg[] | A string-list of parameters |
|
||||
|
||||
**Returns:** *T.AsyncFunction*
|
||||
|
||||
@@ -131,7 +143,9 @@ ___
|
||||
|
||||
*Implementation of [Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Defined in Frontend.ts:36
|
||||
Defined in Frontend.ts:68
|
||||
|
||||
Closes the socket. It may attempt to reconnect.
|
||||
|
||||
**Returns:** *void*
|
||||
|
||||
@@ -141,7 +155,9 @@ ___
|
||||
|
||||
▸ **connect**(): *Promise‹void›*
|
||||
|
||||
Defined in Frontend.ts:48
|
||||
Defined in Frontend.ts:93
|
||||
|
||||
Connects to the server and attaches available RPCs to this object
|
||||
|
||||
**Returns:** *Promise‹void›*
|
||||
|
||||
@@ -153,7 +169,9 @@ ___
|
||||
|
||||
*Implementation of [Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Defined in Frontend.ts:32
|
||||
Defined in Frontend.ts:61
|
||||
|
||||
Destroys the socket
|
||||
|
||||
**Returns:** *void*
|
||||
|
||||
@@ -161,18 +179,20 @@ ___
|
||||
|
||||
### fire
|
||||
|
||||
▸ **fire**(`rpcname`: T.Name, ...`args`: T.Any[]): *Promise‹T.Any›*
|
||||
▸ **fire**(`rpcname`: T.Name, ...`args`: T.Any[]): *Promise‹void›*
|
||||
|
||||
Defined in Frontend.ts:44
|
||||
Defined in Frontend.ts:86
|
||||
|
||||
An alternative to call that does not wait for confirmation and doesn't return a value.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`rpcname` | T.Name |
|
||||
`...args` | T.Any[] |
|
||||
Name | Type | Description |
|
||||
------ | ------ | ------ |
|
||||
`rpcname` | T.Name | The function to call |
|
||||
`...args` | T.Any[] | other arguments |
|
||||
|
||||
**Returns:** *Promise‹T.Any›*
|
||||
**Returns:** *Promise‹void›*
|
||||
|
||||
___
|
||||
|
||||
@@ -180,14 +200,20 @@ ___
|
||||
|
||||
▸ **hook**(`name`: T.Name, `handler`: function): *[Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Defined in Frontend.ts:20
|
||||
Defined in Frontend.ts:37
|
||||
|
||||
Hooks a handler to a function name. Use [call](_frontend_.rpcsocket.md#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:**
|
||||
@@ -204,14 +230,16 @@ ___
|
||||
|
||||
▸ **hookGenerator**(`fnName`: T.Name, `fnArgs`: T.Arg[]): *T.HookFunction*
|
||||
|
||||
Defined in Frontend.ts:79
|
||||
Defined in Frontend.ts:137
|
||||
|
||||
Utility [HookFunction](../modules/_types_.md#hookfunction) generator
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`fnName` | T.Name |
|
||||
`fnArgs` | T.Arg[] |
|
||||
Name | Type | Description |
|
||||
------ | ------ | ------ |
|
||||
`fnName` | T.Name | The function name |
|
||||
`fnArgs` | T.Arg[] | A string-list of parameters |
|
||||
|
||||
**Returns:** *T.HookFunction*
|
||||
|
||||
@@ -221,7 +249,9 @@ ___
|
||||
|
||||
▸ **info**(): *Promise‹any›*
|
||||
|
||||
Defined in Frontend.ts:69
|
||||
Defined in Frontend.ts:117
|
||||
|
||||
Get a list of available RPCs from the server
|
||||
|
||||
**Returns:** *Promise‹any›*
|
||||
|
||||
@@ -231,14 +261,20 @@ ___
|
||||
|
||||
▸ **on**(`type`: "error" | "close", `f`: function): *[Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Defined in Frontend.ts:28
|
||||
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:**
|
||||
@@ -255,12 +291,14 @@ ___
|
||||
|
||||
▸ **unhook**(`name`: T.Name): *[Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Defined in Frontend.ts:24
|
||||
Defined in Frontend.ts:45
|
||||
|
||||
Removes a [hook](_frontend_.rpcsocket.md#hook) listener by name.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
Name | Type |
|
||||
------ | ------ |
|
||||
`name` | T.Name |
|
||||
Name | Type | Description |
|
||||
------ | ------ | ------ |
|
||||
`name` | T.Name | The function name |
|
||||
|
||||
**Returns:** *[Socket](../interfaces/_interfaces_.socket.md)*
|
||||
|
||||
Reference in New Issue
Block a user