Classes
- Message
Message Class
Represents a message in a chatroom
- ChatRoom
ChatRoom Class
Represents a chat room
Functions
- bindChat(forum) ⇒
User
Create a ChatRoom class and bind it to a forum instance
Message
Message Class
Represents a message in a chatroom
Kind: global class
Access: public
- Message
- new Message(payload)
- instance
- static
new Message(payload)
Construct a Message object from payload
This constructor is intended to be private use only, if you need to construct a chat message from payload
data use Message.parse()
instead
Param | Type | Description |
---|---|---|
payload | * |
Payload to construct the Message object out of |
message.id ⇒ number
Chat message id
Kind: instance property of Message
Returns: number
- Id of the chat message
Access: public
message.room ⇒ number
Id of the chatroom this message belongs to
Kind: instance property of Message
Returns: number
- Id of the ChatRoom this message belongs to
Access: public
message.from ⇒ User
User who sent this message
Kind: instance property of Message
Returns: User
- User who authored this chat message
Access: public
message.self ⇒ boolean
Identify if this message was created by current user
Kind: instance property of Message
Returns: boolean
- True if message was sent by current user
Access: public
message.content ⇒ string
Text content of message
Kind: instance property of Message
Returns: string
- Content of the message with formatting and quotes removed
Access: public
message.sent ⇒ Date
DateTime the message was sent
Kind: instance property of Message
Returns: Date
- datetime the message was sent
Access: public
message.markup() ⇒ Promise.<string>
Message markup
Kind: instance method of Message
Returns: Promise.<string>
- Resolves to the HTML markup of the chat message
Access: public
message.reply(content) ⇒ Promise
Reply to the chat message
Kind: instance method of Message
Returns: Promise
- Resolves once message has been sent
Access: public
Param | Type | Description |
---|---|---|
content | string |
Message to reply with |
Message.parse(payload) ⇒ Message
Parse a Message from a given payload
Kind: static method of Message
Returns: Message
- parsed Message
Access: public
Param | Type | Description |
---|---|---|
payload | string | object |
Data to parse as a Message |
ChatRoom
ChatRoom Class
Represents a chat room
Kind: global class
Access: public
- ChatRoom
- new ChatRoom(payload)
- instance
- .id ⇒
number
- .name ⇒
string
- .users ⇒
Array.<User>
- .participants ⇒
number
- .owner ⇒
User
- .url() ⇒
Promise.<string>
- .send(content) ⇒
Promise
- .addUsers(users) ⇒
Promise
- .removeUsers(users) ⇒
Promsie
- .leave() ⇒
Promise
- .rename(newName) ⇒
Promise
- .id ⇒
- static
new ChatRoom(payload)
Construct a ChatroomObject from payload
This constructor is intended to be private use only, if you need to construct a chatroom from payload
data use ChatRoom.parse()
instead
Param | Type | Description |
---|---|---|
payload | * |
Payload to construct the ChatRoom object out of |
chatRoom.id ⇒ number
Get the chatroom id
Kind: instance property of ChatRoom
Returns: number
- Id of the chatroom
Access: public
chatRoom.name ⇒ string
Get the chatroom name
Kind: instance property of ChatRoom
Returns: string
- Name of the chatroom
Access: public
chatRoom.users ⇒ Array.<User>
Get the users in the chatroom
Kind: instance property of ChatRoom
Returns: Array.<User>
- The users that were in teh chatroom when the room was retrieved
Access: public
chatRoom.participants ⇒ number
Get the number of users in the chatroom
Kind: instance property of ChatRoom
Returns: number
- Number of users in the chatroom
Access: public
chatRoom.owner ⇒ User
Get the owner of the chatroom
Kind: instance property of ChatRoom
Returns: User
- Owning user for the chatroom
Access: public
chatRoom.url() ⇒ Promise.<string>
Retrieve the weblink for the Chatroom
Kind: instance method of ChatRoom
Returns: Promise.<string>
- Resolves to the URL web link to the chatroom
Access: public
chatRoom.send(content) ⇒ Promise
Send a message to the chatroom
Kind: instance method of ChatRoom
Returns: Promise
- Resolves when message has been sent
Access: public
Param | Type | Description |
---|---|---|
content | string |
Message to send to the chatroom |
chatRoom.addUsers(users) ⇒ Promise
Add a list of users to the chatroom
Kind: instance method of ChatRoom
Returns: Promise
- Resolves when all users have been added to the chatroom
Access: public
Param | Type | Description |
---|---|---|
users | User | Array.<User> |
User or Users to add to the chatroom |
chatRoom.removeUsers(users) ⇒ Promsie
Remove a list of users from the chatroom
Kind: instance method of ChatRoom
Returns: Promsie
- Resos when users have been removed from the chatroom
Access: public
Param | Type | Description |
---|---|---|
users | User | Array.<User> |
User or Users to remove from the chatroom |
chatRoom.leave() ⇒ Promise
Leave the chatroom
This will remove current user from the chat.
Kind: instance method of ChatRoom
Returns: Promise
- Resolves when chatroom has been left
Access: public
chatRoom.rename(newName) ⇒ Promise
Rename the chat room
Kind: instance method of ChatRoom
Returns: Promise
- Resolves when rename is complete
Access: public
Param | Type | Description |
---|---|---|
newName | string |
Name to set the chatroom to |
ChatRoom.create(users, message, [title]) ⇒ Promise
Create a new chatroom, add a list of users to it and send a message.
Kind: static method of ChatRoom
Returns: Promise
- Resolves once message has been sent
Access: public
Param | Type | Description |
---|---|---|
users | User | Array.<User> |
User or users to add to the chatroom |
message | string |
Message to send to the new chat room |
[title] | string |
Optional: Set the title of the chat message to this value |
ChatRoom.activate()
Activate chat features. newly received chat messages will be processed
Kind: static method of ChatRoom
Access: public
ChatRoom.deactivate()
Deactivate the Chat features. This will stop new chat messages from being processed
Kind: static method of ChatRoom
Access: public
ChatRoom.get(roomId) ⇒ Promise.<ChatRoom>
Retrieve a ChatRoom by a given ID
Kind: static method of ChatRoom
Returns: Promise.<ChatRoom>
- Resolves to the chatroom requested
Access: public
Param | Type | Description |
---|---|---|
roomId | number |
Id of the chatroom to retrieve |
ChatRoom.parse(payload) ⇒ ChatRoom
Parse a Chatroom object from payload
Kind: static method of ChatRoom
Returns: ChatRoom
- Parsed Chatroom
Access: public
Param | Type | Description |
---|---|---|
payload | string | object |
ChatRoom Payload |
bindChat(forum) ⇒ User
Create a ChatRoom class and bind it to a forum instance
Kind: global function
Returns: User
- A ChatRoomPo class bound to the provided forum
instance
Param | Type | Description |
---|---|---|
forum | Provider |
A forum instance to bind to constructed ChatRoom class |
- bindChat(forum) ⇒
User
- ~sendChat(roomId, content) ⇒
Promise
- ~retryAction(fn, trials) ⇒
Promise
- ~sendChat(roomId, content) ⇒
bindChat~sendChat(roomId, content) ⇒ Promise
Send a message to the chatroom
Kind: inner method of bindChat
Returns: Promise
- Resolves when message has been sent
Access: public
Param | Type | Description |
---|---|---|
roomId | number |
Chatroom to speak to |
content | string |
Message to send to the chatroom |
bindChat~retryAction(fn, trials) ⇒ Promise
Kind: inner method of bindChat
Returns: Promise
- Resolves when
Param | Type | Description |
---|---|---|
fn | function |
Promise returning function to possibly retry |
trials | number |
Number or times to retry |