Class: MessageManager

MessageManager()

MessageManager is a browser-side and server-side SDK, please use global function createMessageManager to get instance

Constructor

new MessageManager()

Please use global function createMessageManager to instead of new a MessageManager instance
Source:

Methods

blockUser(chatroomName, user) → {Promise}

Block the user/users to BLOCKED role from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
user object | array a single user object or an array of user objects, user object should include label (int type). You can get user object from registerd events which is started with `user_` or from `getUsers` API
Source:
Returns:
a promise
Type
Promise

changeChatWriteMode(chatroomName, mode) → {Promise}

Change a chat write mode from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
mode string ALL|LOGIN|ANCHOR
Source:
Returns:
a promise
Type
Promise

connect(chatroomName, options) → {Promise}

Connect to a specific chat room, by chatroomName, which is defined by developers
Parameters:
Name Type Description
chatroomName string chat room name
options object
Properties
Name Type Description
events object
Properties
Name Type Description
user_meta:(self) function triggers when user meta are arrived
user_update:(users) function triggers when users are updated
user_add:(users) function triggers when new users are arrived
user_remove:(users) function triggers when users left the chat room
chat_meta:(meta) function triggers when chat room meta are arrived
chat_write_mode:(chatWriteMode) function triggers when chat_write_mode is changed
message_input_interval:(inputInterval) function triggers when message_input_interval is changed, usually happen when message number is too large
user_count:(userCount) function triggers when server automatically broadcasting user count
messages:(msg) function triggers when new messages are arrived
message_flush function triggers when admin clean up all the messages
message_remove:(mid) function triggers when single message is removed
aggregated_data_add:(msg) function triggers when new aggregated messages are arrived
raw_data_add:(msg) function triggers when new raw messages are arrived
meta:(msg) function triggers when meta are arrived
events.connection_status:(status) function triggers chat room status is changed
Source:
Returns:
a promise
Type
Promise

disconnect(chatroomName) → {Promise}

Disconnect from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
a promise
Type
Promise

flushMessage(chatroomName) → {Promise}

Flush all messages from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
a promise
Type
Promise

getAggregatedData(chatroomName, options) → {object}

Return aggregate data in a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
options object
Properties
Name Type Description
page number undefined or null imply no shift, default is 1
perPage number default is 10 and MAX is 100
oldestDate number unix time in millisecond, ex: 1406183498018, undefined or null imply no constraint
latestDate number unix time in millisecond, ex: 1406183498018, undefined or null imply no constraint
order string asc|desc, order by created_date with asc or desc ordering, default is desc
Source:
Returns:
messages - array of messages
Type
object

getChatroomMeta(chatroomName) → {object}

Show related meta for a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
meta object of chat room
Type
object

getConnectedRooms() → {array}

Show all the connected chat room
Source:
Returns:
names of all connected chat rooms
Type
array

getCurrentUserInChatroom(chatroomName) → {object}

Return the current user related meta in a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
user meta object
Type
object

getMessages(chatroomName, options) → {object}

Return all messages in a specific chat room If there are over 5000 people in the chat room, it responds empty array
Parameters:
Name Type Description
chatroomName string chat room name
options object
Properties
Name Type Description
page number undefined or null imply no shift, default is 1
perPage number default is 10 and MAX is 100
oldestDate number unix time in millisecond, ex: 1406183498018, undefined or null imply no constraint
latestDate number unix time in millisecond, ex: 1406183498018, undefined or null imply no constraint
order string asc|desc, order by created_date with asc or desc ordering, default is desc
Source:
Returns:
messages - array of messages
Type
object

getMeta(chatroomName, keys) → {object}

Get meta from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
keys array to get, return all if not specified
Source:
Returns:
meta - array of metas
Type
object

getPinnedMessage(chatroomName) → {Promise}

Get pinned message from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
a promise
Type
Promise

getRawData(chatroomName, options) → {object}

Return raw data in a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
options object
Properties
Name Type Description
page number undefined or null imply no shift, default is 1
perPage number default is 10 and MAX is 100
oldestDate number unix time in millisecond, ex: 1406183498018, undefined or null imply no constraint
latestDate number unix time in millisecond, ex: 1406183498018, undefined or null imply no constraint
order string asc|desc, order by created_date with asc or desc ordering, default is desc
Source:
Returns:
messages - array of messages
Type
object

getRoomStatus(chatroomName) → {string}

Get status from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
DISCONNECTING|CONNECTING|CONNECTED|IDLE|NOT_USE
Type
string

getSendMessageInterval(chatroomName) → {int}

Returns send message interval of current chatroom.
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
Interval in second
Type
int

getTotalAggregatedData(chatroomName) → {array}

Get all aggregated data from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
an array of aggregated data key and n
Type
array

getUsers(chatroomName, userType) → {object}

Return all a specific type of users in a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
userType string onlineUser|blocked|supervisor, onlineUser=[GLOBAL_MANAGER, LOCAL_MANAGER, MASTER, MODERATOR, NORMAL] ; blocked=[BLOCKED] ; supervisor=[GLOBAL_MANAGER, LOCAL_MANAGER, MODERATOR]
Source:
Returns:
users - array of users
Type
object

init() → {Promise}

To call Init function is required, after getting MessageManager instance from function createMessageManager
Source:
Returns:
a promise
Type
Promise

pinMessage(chatroomName, messageId) → {Promise}

Pin a message by message id from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
messageId string message id to pin
Source:
Returns:
a promise
Type
Promise

removeMessage(chatroomName, messageId) → {Promise}

Remove a message by message id from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
messageId string message id to remove
Source:
Returns:
a promise
Type
Promise

reviveUser(chatroomName, user) → {Promise}

Revive the user/users to NORMAL role from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
user object | array a single user object or an array of user objects, user object should include label (int type). You can get user object from registerd events which is started with `user_` or from `getUsers` API
Source:
Returns:
a promise
Type
Promise

sendAggregatedDataTypeMessage(chatroomName, message) → {Promise}

Send a string to a specific chat room which is aggregated in aggregated_data_add
Parameters:
Name Type Description
chatroomName string chat room name
message string a simple string, e.g. "like", "cry", should within 100 characters
Source:
Returns:
a promise
Type
Promise

sendMessage(chatroomName, message) → {Promise}

Send message to a specific chat room This method can't be call more than once within one second
Parameters:
Name Type Description
chatroomName string chat room name
message string a simple string, e.g. "abc", should within 300 characters
Source:
Returns:
a promise
Type
Promise

sendRawData(chatroomName, message) → {Promise}

Send the raw data to a specific chat room, this type of message is not aggregated
Parameters:
Name Type Description
chatroomName string chat room name
message string a json or array type of message, e.g. "{ id: 1 } or [{ id: 1 }]", should within 2048 characters
Source:
Returns:
a promise
Type
Promise

setMeta(chatroomName, key, value, broadcast) → {Promise}

Set meta in a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
key string indicate the meta key, shouldn't start with _
value object indicate the meta value
broadcast bool indicate meta is broadcast or not
Source:
Returns:
a promise
Type
Promise

unpinMessage(chatroomName) → {Promise}

Unpin a pinned message from a specific chat room
Parameters:
Name Type Description
chatroomName string chat room name
Source:
Returns:
a promise
Type
Promise

updateNickName(chatroomName, nickname) → {Promise}

Update the current user's nickname
Parameters:
Name Type Description
chatroomName string chat room name
nickname string a nickname to update
Source:
Returns:
a promise
Type
Promise

updateUserRole(chatroomName, user, role) → {Promise}

Update the role by user object for a specific user
Parameters:
Name Type Description
chatroomName string chat room name
user object the user object of a specific user
role string MODERATOR|NORMAL
Source:
Returns:
a promise
Type
Promise

updateUserRoleByMemberId(chatroomName, memberId, role) → {Promise}

Update the role by member id for a specific user
Parameters:
Name Type Description
chatroomName string chat room name
memberId string the member id of a specific user
role string MODERATOR|NORMAL
Source:
Returns:
a promise
Type
Promise