Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface ClientOptions

Hierarchy

  • ClientOptions

Index

Properties

address

address: string

Server's address ex. wss://192.168.1.1/ws

Optional handshake

handshake: undefined | ((result: boolean) => void)

The function that will be called when the connection is established

param

The result of the handshaking. If true - everything is ok. Otherwise - server doesn't allow connection and the websocket is closed

Optional prepareContext

prepareContext: undefined | ((ctx: RPCContext) => any)

Optional function to define initial context for the Client.register handlers. By default it returns the RPCContext object

param

An object with the id property. Where id - is a unique method call identifier

example
const client = new Client({
  ...
  prepareContext: (ctx) => ({ ...ctx, useWS: true }),
});
client.register('ping', (params, context) => {
  console.log(context.id, 'client ping', params, ctx.useWS);
});

Optional protocols

protocols: string | string[]

Set of protocols inherited from {@link WebSocket.constructor}

token

token: Id

Unique id for the client

Generated using TypeDoc