Class MessagingChatSocketApi<MessageCustomFields>

Type Parameters

  • MessageCustomFields = unknown

Hierarchy

  • BaseSocketApi
    • MessagingChatSocketApi

Implements

Constructors

Properties

clientSocket: null | Socket<DefaultEventsMap, DefaultEventsMap> = null
serviceEndpoint: string
sessionService: SessionService
socketIOOptions: Partial<ManagerOptions & SocketOptions> = {}
subscriptionTimeout: number = 5000
subscriptions: {
    onError: ((error) => void);
    onMessage: ((message) => void);
    organizationId?: string;
    userId?: string;
}[] = []

Type declaration

  • onError: ((error) => void)
      • (error): void
      • Parameters

        • error: string

        Returns void

  • onMessage: ((message) => void)
      • (message): void
      • Parameters

        Returns void

  • Optional organizationId?: string
  • Optional userId?: string

Methods

  • Returns Promise<void>

  • Returns Promise<void>

  • On setup, we can call getRequiredVersion and ping() to confirm that the service exists and that it is of a matching version semantically E.g. if required version is ~2.5 and the api returns 2.6.3, then no issue If returns 3.0.1, should log a warning If returns 1.0.2, should throw error saying it isn't new enough

    Returns string

  • Returns Partial<ManagerOptions & SocketOptions>

  • Parameters

    • error: string

    Returns Promise<void>

  • Parameters

    • message: unknown

    Returns Promise<void>

  • Register callback for relevant events for the given organizationId This will set up a new socket connection if not currently connected.

    If the given org is not currently subscribed, it will send a subscribe event to the backend, otherwise do nothing.

    When message events occur, onMessage will be called.

    Parameters

    • input: {
          onError: ((error) => void);
          onMessage: ((message) => void);
          organizationId: string;
      }
      • onError: ((error) => void)
          • (error): void
          • Parameters

            • error: string

            Returns void

      • onMessage: ((message) => void)
          • (message): void
          • Parameters

            Returns void

      • organizationId: string

    Returns Promise<void>

  • Register callback for relevant events for the given userId This will set up a new socket connection if not currently connected.

    If the given org is not currently subscribed, it will send a subscribe event to the backend, otherwise do nothing.

    When message events occur, onMessage will be called.

    Parameters

    • input: {
          onError: ((error) => void);
          onMessage: ((message) => void);
          userId: string;
      }
      • onError: ((error) => void)
          • (error): void
          • Parameters

            • error: string

            Returns void

      • onMessage: ((message) => void)
          • (message): void
          • Parameters

            Returns void

      • userId: string

    Returns Promise<void>

  • Removes subscriptions for the given organizationId.

    If all subscriptions are removed, then the socket connection will be closed after a short timeout.

    Parameters

    • input: {
          organizationId: string;
      }
      • organizationId: string

    Returns Promise<void>

  • Removes subscriptions for the given userId.

    If all subscriptions are removed, then the socket connection will be closed after a short timeout.

    Parameters

    • input: {
          userId: string;
      }
      • userId: string

    Returns Promise<void>

Generated using TypeDoc