Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • EventEmitter<Events, Listeners>
    • PChatSDK

Index

Constructors

constructor

  • Returns PChatSDK

Properties

messages

messages: MessageType[] = []

List of all messages sorted from oldest to most recent.

state

state: States = States.DISCONNECTED

Connection state.

user

user: null | UserType = null

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

Accessors

Errors

Events

States

Methods

connect

  • connect(room: string, username: string, token: string): Promise<void>

disconnect

  • disconnect(): void

loadOlder

  • loadOlder(timestamp?: string): Promise<PChatSDK>
  • Used for loading older chat room's history. Consecutive calls will be handled in a queue. Triggers Events.HISTORY_LOAD on success.

    throws

    PChatError

    Parameters

    • Optional timestamp: string

      Timestamp to load messages before, by default oldest message's timestamp is used

    Returns Promise<PChatSDK>

off

  • off(): void
  • off<E>(event: E): void
  • off<E>(events: E[]): void
  • off<E>(event: E, listener: EventListener<Listeners[E]>): void
  • off<E>(events: E[], listener: EventListener<Listeners[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<Listeners[E]>

    Returns void

  • Removes specific listener for multiple events.

    Type parameters

    Parameters

    • events: E[]
    • listener: EventListener<Listeners[E]>

    Returns void

on

  • on<E>(event: E, listener: EventListener<Listeners[E]>): void
  • on<E>(events: E[], listener: EventListener<Listeners[E]>): void
  • Adds listener for event.

    Type parameters

    Parameters

    • event: E
    • listener: EventListener<Listeners[E]>

    Returns void

  • Adds the same listener for multiple events.

    Type parameters

    Parameters

    • events: E[]
    • listener: EventListener<Listeners[E]>

    Returns void

publish