Websocket Connection wrapper, can be used to create integration-tests for applications.

Hierarchy

Constructors

Properties

_id: number = ++WebsocketConnection.AUTO_INCREMENT

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

clientInformation: {
    browser: string;
    ip: string;
    location: string;
}

Information about the client connected to the WebSocket.

Type declaration

  • browser: string
  • ip: string
  • location: string
connection: WebSocket

The WebSocket connection object representing the connection to the client.

description: string = "PUBLIC"

Describes the clients auth state

messageId: number = 0
rejects: Map<number, Function> = ...
stack: {
    func: Function;
    hashCallback: string | ((specificHash, inserted, updated, deleted) => void);
    method: string;
    outboundMethod: string;
}[] = []

Type declaration

  • func: Function
  • hashCallback: string | ((specificHash, inserted, updated, deleted) => void)
  • method: string
  • outboundMethod: string
testingIdentifier: number
token: string = null

Can be used to store session credentials.

maxTestingIdentifier: number = 0
router: WebsocketRouter = ...

Refers to a websocket router instance.

Accessors

Methods

  • Does not expect to receive the method - if received, an error is thrown.

    Parameters

    • method: string

      The method that should not be expected.

    Returns Promise<void>

    A promise that is rejected with an error if the method is received.

  • This method is used to react to a specific message in a test case. The promises will be resolved in the order of the expected methods. All previously expected methods have to be received, before the method is expected.

    Parameters

    • method: string

      A message with this method is expected.

    • Optional messageId: number
    • Optional timeout: number

      Timeout value in milliseconds before test fails.

    • Optional hashCallback: ((specificHash, inserted, updated, deleted) => void)
        • (specificHash, inserted, updated, deleted): void
        • Parameters

          • specificHash: number
          • inserted: any[]
          • updated: any[]
          • deleted: any[]

          Returns void

    Returns Promise<any>

    Promise, that is resolved once the provided method is received.

  • 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
  • Sends a WebSocket message.

    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 Promise<unknown>

    true if the message is handled, false otherwise.

  • 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

  • Wait a given amount of ms during a test case.

    Parameters

    • ms: number

      Time duration in milliseconds before the promise is resolved.

    Returns Promise<void>

    Promise, that is resolved after the given amount of milliseconds.

  • 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