Interface ChatSocketApi<MessageCustomFields>

interface ChatSocketApi {
    serviceEndpoint: string;
    sessionService: SessionService;
    getPaginatedQueryParams(query): string;
    getPaginatedResponse<T>(backendResponse): PaginatedResponse<T>;
    getRequiredVersion(): string;
    getServiceUrl(path): string;
    ping(): Promise<PingResponse>;
    subscribeToOrganizationId(input): Promise<void>;
    subscribeToUserId(input): Promise<void>;
    unsubscribeToOrganizationId(input): Promise<void>;
    unsubscribeToUserId(input): Promise<void>;
}

Type Parameters

  • MessageCustomFields = unknown

Hierarchy

Implemented by

Properties

serviceEndpoint: string
sessionService: SessionService

Methods

  • 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

  • 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