Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

Index

Constructors

constructor

  • Returns ChatSDK

Properties

state

state: States = States.DISCONNECTED

Connection state.

user

user: null | UserType = null

Authorized user. Will be initialized on successful ChatSDK.connect.

Accessors

Errors

Events

States

rooms

Methods

connect

  • connect(token: string): Promise<void>

createRoom

  • createRoom(ids: string[], name: string): Promise<null | Room>
  • Used for creating a chat room. Triggers ChatEvents.ROOM_ADDED on success.

    throws

    ChatError

    Parameters

    • ids: string[]

      Ids of users to invite to the room

    • name: string

      Room's name

    Returns Promise<null | Room>

disconnect

  • disconnect(): void

leaveRoom

  • leaveRoom(id: string): Promise<void>

off

  • off(): void
  • off<E>(event: E): void
  • off<E>(events: E[]): void
  • off<E>(event: E, listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>): void
  • off<E>(events: E[], listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>): void
  • Removes all listeners.

    Returns void

  • Removes all listeners for event.

    Type parameters

    Parameters

    • event: E

    Returns void

  • Removes all listeners for events.

    Type parameters

    Parameters

    • events: E[]

    Returns void

  • Removes specific listener for event.

    Type parameters

    Parameters

    • event: E
    • listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>

    Returns void

  • Removes specific listener for multiple events.

    Type parameters

    Parameters

    • events: E[]
    • listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>

    Returns void

on

  • on<E>(event: E, listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>): void
  • on<E>(events: E[], listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>): void
  • Adds listener for event.

    Type parameters

    Parameters

    • event: E
    • listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>

    Returns void

  • Adds the same listener for multiple events.

    Type parameters

    Parameters

    • events: E[]
    • listener: EventListener<ChatListeners & RoomListeners & HistoryListeners[E]>

    Returns void

room

  • room(id: string): undefined | Room
  • Get user's room by id.

    Parameters

    • id: string

    Returns undefined | Room

setUsername

  • setUsername(username: string): Promise<UserType>