WebSocketAPI - v1.1.5-1 › Globals › "client/index"
• onSnapshot:
▸ api(api: string): object
Defined in lib/client/index.ts:140
Parameters:
| Name | Type |
|---|---|
api |
string |
Returns: object
-
delete(
body: any,options?: requestOptions): Promise‹any› -
get(
body: any,options?: requestOptions): Promise‹any› -
post(
body: any,options?: requestOptions): Promise‹any› -
put(
body: any,options?: requestOptions): Promise‹any› -
snapshot(
body: any,callback: function): function- (): void
▸ fetch(api: string, body?: any, options?: requestOptions): Promise‹any›
Defined in lib/client/index.ts:282
Make a new api request
Parameters:
| Name | Type | Description |
|---|---|---|
api |
string | the api endpoint to call |
body? |
any | the data to include in the fetch call |
options? |
requestOptions | any options for the request |
Returns: Promise‹any›
▸ getCurrentConnection(): null | WebSocket
Defined in lib/client/index.ts:315
Returns the current web socket connection. This will be null if there isn't a active connection
Returns: null | WebSocket
▸ getCurrentState(): "OPEN" | "CLOSED" | "ERROR" | "READY" | "AUTHFAILED"
Defined in lib/client/index.ts:325
Returns the current state of the web socket
Returns: "OPEN" | "CLOSED" | "ERROR" | "READY" | "AUTHFAILED"
▸ getData(id: number, api: string, body?: any, options?: requestOptions): Promise‹any›
Defined in lib/client/index.ts:180
Request a get or delete
Parameters:
| Name | Type |
|---|---|
id |
number |
api |
string |
body? |
any |
options? |
requestOptions |
Returns: Promise‹any›
▸ newIndex(): number
Defined in lib/client/index.ts:72
Returns: number
▸ on(api: string, callback: function): eventObject
Defined in lib/client/index.ts:308
Register a event listener for events sent from the server
Parameters:
▪ api: string
The api name
▪ callback: function
the callback function
▸ (event: Request): void
Parameters:
| Name | Type |
|---|---|
event |
Request |
Returns: eventObject
▸ reconnect(): void
Defined in lib/client/index.ts:332
Attempt to reconnect to the server
Returns: void
▸ sendData(id: number, api: string, body?: any, options?: requestOptions): Promise‹any›
Defined in lib/client/index.ts:235
Send any post or put data
todo Add the timeout error
Parameters:
| Name | Type |
|---|---|
id |
number |
api |
string |
body? |
any |
options? |
requestOptions |
Returns: Promise‹any›
▸ setup(options: Options): void
Defined in lib/client/index.ts:107
Setup the client side api with the correct parameters
Parameters:
| Name | Type | Description |
|---|---|---|
options |
Options | the options for the client side application |
Returns: void
Defined in lib/client/index.ts:79
The currently using options object
• fetchUrl: string = "/api"
Defined in lib/client/index.ts:80
• maxSocketLength: number = 10000
Defined in lib/client/index.ts:90
• reconnect: true = true
Defined in lib/client/index.ts:88
• reconnectTimeOut: number = 500
Defined in lib/client/index.ts:91
• url: object
Defined in lib/client/index.ts:89
• websocketUrl: string = "/api"
Defined in lib/client/index.ts:81
▸ stateChange(): void
Defined in lib/client/index.ts:98
Returns: void
▸ unHandledWebSocketMessage(err: Error, message: string): void
Defined in lib/client/index.ts:92
Parameters:
| Name | Type |
|---|---|
err |
Error |
message |
string |
Returns: void
▸ websocketOnMessage(message: string): void
Defined in lib/client/index.ts:82
Parameters:
| Name | Type |
|---|---|
message |
string |
Returns: void