Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • RealtimeClient

Index

Constructors

  • Initializes the Socket.

    Parameters

    • endPoint: string

      The string WebSocket endpoint, ie, "ws://example.com/socket", "wss://example.com", "/socket" (inherited host & protocol)

    • Optional options: RealtimeClientOptions

    Returns RealtimeClient

Properties

_workerObjectUrl: any
accessToken: null | string
apiKey: null | string
channels: RealtimeChannel[]
conn: null | WebSocketLike
decode: Function
encode: Function
endPoint: string
fetch: ((input: RequestInfo | URL, init?: RequestInit) => Promise<Response>)

Type declaration

    • (input: RequestInfo | URL, init?: RequestInit): Promise<Response>
    • Parameters

      • input: RequestInfo | URL
      • Optional init: RequestInit

      Returns Promise<Response>

headers?: {}

Type declaration

  • [key: string]: string
heartbeatIntervalMs: number
heartbeatTimer: undefined | Timer
httpEndpoint: string
logger: Function
params?: {}

Type declaration

  • [key: string]: string
pendingHeartbeatRef: null | string
reconnectAfterMs: Function
reconnectTimer: default
ref: number
sendBuffer: Function[]
serializer: default
stateChangeCallbacks: { close: Function[]; error: Function[]; message: Function[]; open: Function[] }

Type declaration

  • close: Function[]
  • error: Function[]
  • message: Function[]
  • open: Function[]
timeout: number
transport: null | WebSocketLikeConstructor
worker?: boolean
workerRef?: Worker
workerUrl?: string

Methods

  • connect(): void
  • Connects the socket, unless already connected.

    Returns void

  • connectionState(): CONNECTION_STATE
  • Returns the current state of the socket.

    Returns CONNECTION_STATE

  • disconnect(code?: number, reason?: string): void
  • Disconnects the socket.

    Parameters

    • Optional code: number

      A numeric status code to send on disconnect.

    • Optional reason: string

      A custom reason for the disconnect.

    Returns void

  • Returns all created channels

    Returns RealtimeChannel[]

  • isConnected(): boolean
  • Returns true is the connection is open.

    Returns boolean

  • log(kind: string, msg: string, data?: any): void
  • Logs the message.

    For customized logging, this.logger can be overridden.

    Parameters

    • kind: string
    • msg: string
    • Optional data: any

    Returns void

  • Push out a message if the socket is connected.

    If the socket is not connected, the message gets enqueued within a local buffer, and sent out when a connection is next established.

    Parameters

    Returns void

  • Unsubscribes and removes all channels

    Returns Promise<RealtimeRemoveChannelResponse[]>

  • Unsubscribes and removes a single channel

    Parameters

    Returns Promise<RealtimeRemoveChannelResponse>

  • setAuth(token: null | string): void
  • Sets the JWT access token used for channel subscription authorization and Realtime RLS.

    Parameters

    • token: null | string

      A JWT string.

    Returns void

Generated using TypeDoc