Skip to content

Latest commit

 

History

History
307 lines (171 loc) · 7.64 KB

File metadata and controls

307 lines (171 loc) · 7.64 KB

WebSocketAPI - v1.1.5-1Globals"client/index"

Module: "client/index"

Index

References

Interfaces

Functions

Object literals

References

onSnapshot

onSnapshot:

Functions

api

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

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

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

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

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

newIndex(): number

Defined in lib/client/index.ts:72

Returns: number


on

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

reconnect(): void

Defined in lib/client/index.ts:332

Attempt to reconnect to the server

Returns: void


sendData

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

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

Object literals

Const setOptions

setOptions: object

Defined in lib/client/index.ts:79

The currently using options object

fetchUrl

fetchUrl: string = "/api"

Defined in lib/client/index.ts:80

maxSocketLength

maxSocketLength: number = 10000

Defined in lib/client/index.ts:90

reconnect

reconnect: true = true

Defined in lib/client/index.ts:88

reconnectTimeOut

reconnectTimeOut: number = 500

Defined in lib/client/index.ts:91

url

url: object

Defined in lib/client/index.ts:89

Type declaration:

websocketUrl

websocketUrl: string = "/api"

Defined in lib/client/index.ts:81

stateChange

stateChange(): void

Defined in lib/client/index.ts:98

Returns: void

unHandledWebSocketMessage

unHandledWebSocketMessage(err: Error, message: string): void

Defined in lib/client/index.ts:92

Parameters:

Name Type
err Error
message string

Returns: void

websocketOnMessage

websocketOnMessage(message: string): void

Defined in lib/client/index.ts:82

Parameters:

Name Type
message string

Returns: void