Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BaseGateway Abstract

label

COMMON

description

This class serves as the base class for custom gateways which are connecting with the client through the websocket.

This class can be used by extending it and adding different

subscribemessage

handlers.

since

v0.2.0

Hierarchy

Implements

  • OnGatewayInit
  • OnGatewayConnection
  • OnGatewayDisconnect

Index

Constructors

  • Construct an instance of the base gateway, initialize clients, logger and emitter properties.

    access

    public

    Parameters

    • emitter: EventEmitter2

      Emitting events once connections/updates appear.

    Returns BaseGateway

Properties

This property implements list of currently connected clients by storing their challenges. Challenge gets removed from list once client disconnects.

access

protected

var

{WebsocketConsumerMap}

emitter: EventEmitter2
logger: LogService

This property permits to log information to the console or in files depending on the configuration. This logger instance can be accessed by extending listeners to use a common log process.

access

protected

var

{LogService}

options: { debug: boolean } = ...

Type declaration

  • debug: boolean
server: Server<typeof IncomingMessage, typeof ServerResponse>

This property implements gateway server which is broadcasts different messages to single or multiple clients.

access

protected

var

{Server}

websocketUrl: string

Contains the full websocket connection URL (including path).

access

protected

var

{string}

Methods

  • afterInit(server: Server<typeof IncomingMessage, typeof ServerResponse>): void
  • This method handles gateway initialize hook.

    access

    public

    Parameters

    • server: Server<typeof IncomingMessage, typeof ServerResponse>

      Websocket connection param, holds server and client info.

    Returns void

    Removes client challenge from list

  • handleConnection(ws: any, req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>): Promise<void>
  • This method handles connection via websocket with the client.

    Additionally, this method will emit the event auth.open given the presence of an authentication challenge in the signed request cookies.

    access

    public

    emits

    OnAuthOpened Given the presence of a challenge in signed cookies of the request.

    throws

    {HttpException} Given a missing or invalid challenge in the signer cookies of the request.

    Parameters

    • ws: any

      UDP datagrap socket used to connect.

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>

      HTTP Request forwarded to enable reading signed client cookies.

    Returns Promise<void>

  • handleDisconnect(ws: any): void
  • This method handles closing connection with the client. After client was disconnected - remove his challenge from list.

    In case of a successful validation attempts, i.e. when the challenge parameter has been found in a recent transfer transaction's message, a document will be insert in the collection authChallenges.

    access

    public

    Parameters

    • ws: any

      Websocket connection param, holds server and client info.

    Returns void

    Removes client challenge from list

Generated using TypeDoc