Skip to content

Latest commit

 

History

History
89 lines (63 loc) · 2.04 KB

File metadata and controls

89 lines (63 loc) · 2.04 KB

Chat

Kind: global class


new Chat(username, userTag)

Param Type Default Description
username String UserA The client's user username
userTag String 000000000000000000000000 The client's user tag

Example

let chat = new Chat('UserA', '4234');


chat.addMessage(username, content, [userTag])

Add a message to the chat box interface

Kind: instance method of Chat

Param Type Description
username String The user name to display
content String The content of the message to display
[userTag] String The user tag (display's next to the name in brackets)

Example

chat.addMessage('UserB', 'Hello world back!', '1241');
  


chat.addPrompt(sendMessage)

add a chat prompt

Kind: instance method of Chat

Param Type Description
sendMessage function Callback with a Message object as argument

Example

// add a prompt and do nothing on enter
  chat.addPrompt(() => {});   

  // add a prompt and `console.log` data on enter
  chat.addPrompt((msg) => {
    console.log(msg);
    // on enter event
  })
  


chat.addFooter(content)

Add a footer (Text at the bottom of the screen

Kind: instance method of Chat

Param Type Description
content String The text writtern in the footer

Example

chat.addFooter('Press ESC-q to quit!');