Options
All
  • Public
  • Public/Protected
  • All
Menu

Represents the main chatexchange Client class.

Hierarchy

  • Client

Index

Constructors

  • Creates an instance of Client.

    throws

    {InvalidArgumentError} If the host is invalid

    Parameters

    • host: Host

      The host to connect to (stackexchange.com, meta.stackexchange.com, or stackoverflow.com)

    Returns Client

Properties

host: Host

Accessors

  • set browser(browser: Browser): void
  • get fkey(): Promise<string>
  • summary

    gets user chat fkey

    memberof

    Client#

    Returns Promise<string>

  • get loggedIn(): boolean
  • get root(): string
  • summary

    Returns the chat host URL

    memberof

    Client#

    Returns string

Methods

  • broadcast(message: string): Promise<Map<number, boolean>>
  • Broadcasts a message to all joined rooms

    Parameters

    • message: string

      message to broadcast

    Returns Promise<Map<number, boolean>>

  • getMe(): Promise<User>
  • Fetches the current logged-in user's profile

    throws

    {ChatExchangeError} If no user is currently logged in

    memberof

    Client#

    Returns Promise<User>

    The user object

  • getRooms(): Map<number, Room>
  • getRoomsAsArray(): Room[]
  • joinRoom(room: number | Room): Promise<boolean>
  • summary

    Joins a given room

    memberof

    Client#

    Parameters

    • room: number | Room

      The room or ID to join

    Returns Promise<boolean>

  • leaveAll(): Promise<boolean>
  • summary

    Leaves all rooms (on same chat server)

    memberof

    Client#

    Returns Promise<boolean>

  • leaveRoom(room: number | Room): Promise<boolean>
  • summary

    Leaves a given room

    Parameters

    • room: number | Room

      The Room or ID to leave

    Returns Promise<boolean>

  • listUsers(room: number | Room): Promise<User[]>
  • summary

    lists users in a given {@link room}

    Parameters

    • room: number | Room

      room or room ID to list current users from

    Returns Promise<User[]>

  • login(email: string, password: string): Promise<string>
  • Attempts to login to the stackexchange network with the provided username and password

    memberof

    Client#

    Parameters

    • email: string

      Email

    • password: string

      Password

    Returns Promise<string>

    Request Cookie Jar (Optionally to save to loginCookie)

  • loginCookie(cookieString: string): Promise<void>
  • Attempts to login to stack exchange, using the provided cookie jar string, which was retrieved from the login method.

    memberof

    Client#

    Parameters

    • cookieString: string

      A cookie jar string

    Returns Promise<void>

    A promise representing when login is complete

  • logout(): Promise<boolean>
  • summary

    attempts to logout from the Stack Exchange network

    memberof

    Client#

    Returns Promise<boolean>

    status of the logout

  • send(message: string, room: number | Room): Promise<[boolean, Message]>
  • summary

    sends a message to a given room

    Parameters

    • message: string

      message to send

    • room: number | Room

      room or room ID to send to

    Returns Promise<[boolean, Message]>

  • watch(room: number | Room): Promise<WebSocket>
  • summary

    watches a given Room for new events

    Parameters

    • room: number | Room

      room or room ID to watch

    Returns Promise<WebSocket>

Generated using TypeDoc