The Chat Bubble Class This application displays a temporary message sent from a particular Token in the active Scene. The message is displayed on the HUD layer just above the Token.

Properties

bubbles: any

Track active Chat Bubbles

Accessors

  • get container(): jQuery
  • A reference to the chat bubbles HTML container in which rendered bubbles should live

    Returns jQuery

Methods

  • Create a chat bubble message for a certain token which is synchronized for display across all connected clients.

    Parameters

    • token: TokenDocument

      The speaking Token Document

    • message: string

      The spoken message text

    • Optional options: ChatBubbleOptions = {}

      Options which affect the bubble appearance

    Returns Promise<any>

    A promise which resolves with the created bubble HTML, or null

  • Speak a message as a particular Token, displaying it as a chat bubble

    Parameters

    • token: Token

      The speaking Token

    • message: string

      The spoken message text

    • Optional options: ChatBubbleOptions = {}

      Options which affect the bubble appearance

    Returns Promise<any>

    A Promise which resolves to the created bubble HTML element, or null

  • Determine the length of time for which to display a chat bubble. Research suggests that average reading speed is 200 words per minute. Since these are short-form messages, we multiply reading speed by 1.5. Clamp the result between 1 second (minimum) and 20 seconds (maximum)

    Parameters

    • html: jQuery

      The HTML message

    Returns number

    The number of milliseconds for which to display the message

  • Private

    Clear any existing chat bubble for a certain Token

    Parameters

    Returns Promise<any>

  • Private

    Render the HTML template for the chat bubble

    Parameters

    • data: any

      Template data

    Returns Promise<string>

    The rendered HTML

  • Private

    Before displaying the chat message, determine it's constrained and unconstrained dimensions

    Parameters

    • message: string

      The message content

    Returns any

    The rendered message dimensions

  • Private

    Assign styling parameters to the chat bubble, toggling either a left or right display (randomly)

    Parameters

    • token: Token

      The speaking Token

    • html: JQuery

      Chat bubble content

    • dimensions: Rectangle

      Positioning data

    Returns void

  • Internal

    Activate Socket event listeners which apply to the ChatBubbles UI.

    Parameters

    • socket: Socket

      The active web socket connection

    Returns void