Class WebsocketConnection

Represents a WebSocket connection.

Hierarchy

Constructors

  • Creates a new instance of WebsocketConnection.

    Parameters

    • connection: WebSocket

      The WebSocket connection object representing the connection to the client.

    • Optional supportsCache: boolean

      Determines whether the client supports caching for outbound data.

    • Optional authToken: string

      An optional parameter used to store authentication credentials, such as session tokens, for the client.

    Returns WebsocketConnection

Properties

_id: number = ++WebsocketConnection.AUTO_INCREMENT

Unique client id per server instance. This incremental value is resetted once the process is restarted.

cachingEnabled: boolean = false
clientInformation: {
    browser: string;
    ip: string;
    location: string;
}

Information about the client connected to the WebSocket.

Type declaration

  • browser: string
  • ip: string
  • location: string
closed: boolean = false
connection: WebSocket

The WebSocket connection object representing the connection to the client.

description: string = "PUBLIC"

Describes the clients auth state

logging: boolean = false
outboundCache: Map<string, any[] | Map<number, any>> = ...
outboundRequestConfig: Map<string, {
    count: number;
    groupId: number;
    id: number;
}> = ...

Type declaration

  • count: number
  • groupId: number
  • id: number
pingInterval: Timeout
token: string = null

Can be used to store session credentials.

AUTO_INCREMENT: number = 0
closeHandlers: DecorableFunction[] = []
lookup: any
router: WebsocketRouter = ...

Refers to a websocket router instance.

Accessors

Methods

  • Sets the cached outbound data for the associated outbound method.

    Parameters

    • method: string

      The method of the associated Outbound.

    • data: any[]

      The contents that should be cached for the method.

    Returns void

  • Calculates the modified rows of data, that have been changed since the last time data was cached.

    Parameters

    • method: string

      The method of the associated Outbound.

    • data: {
          id: number;
      }[]

      The data returned from the outbound function.

    • Optional isPartial: boolean

      True when a part of the data is only present

    Returns {
        data: string | any[];
        deleted: any[];
        inserted: any[];
        updated: any[];
    }

    the data changes (inserted, updated, deleted)

    • data: string | any[]
    • deleted: any[]
    • inserted: any[]
    • updated: any[]
  • Outbound request config is used to store the length of entries, that have been previously requested by this client for partially sent outbounds.

    Parameters

    • method: string

      The method of the outbound

    Returns {
        count: number;
        groupId: number;
        id: number;
    }

    the outbound request config

    • count: number
    • groupId: number
    • id: number
  • Returns {
        browser: string;
        ip: string;
        location: string;
    }

    • browser: string
    • ip: string
    • location: string
  • Sends a message through the WebSocket connection.

    Parameters

    • method: string

      The method of the message.

    • value: any

      The value of the message.

    • Optional messageId: number

      The ID of the message.

    • Optional specificHash: number

      The specific hash value - used by outbounds with caching enabled.

    • Optional inserted: any[]
    • Optional updated: any[]
    • Optional deleted: any[]
    • Optional length: number

    Returns void

  • Outbound request config is used to store the length of entries, that have been previously requested by this client for partially sent outbounds.

    Parameters

    • method: string

      The method of the outbound

    • count: number

      The length of entries that have been requested.

    • groupId: number
    • id: number

    Returns void

  • Updates the cached outbound data for the associated outbound method.

    Parameters

    • method: string

      The method of the associated Outbound.

    • inserted: any[]

      The contents that have been added since the last time.

    • updated: any[]

      The contents that have been modified since the last time.

    • deleted: any[]

      The contents that have been removed since the last time.

    Returns void

Generated using TypeDoc