public class ChatroomManager extends Object
ChatroomManager is used to manage a chatroom or a message board.
 
 You could call initialize() to get a ChatroomManager. This method will check your
 developer credential and construct a ChatroomManager if you are authorized. Then, you
 could call connect(String, Identity) to connect to a chatroom and start using
 other methods.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
ChatroomManager.ChatroomConfig
Configuration for  
ChatroomManager. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
addAllEventListener(EventListener... listeners)  | 
boolean | 
addEventListener(EventListener listener)  | 
void | 
addFakeMessage(Message message)  | 
com.google.android.gms.tasks.Task<Void> | 
blockUsers(List<User> users)
Block target users. 
 | 
com.google.android.gms.tasks.Task<Void> | 
connect(String chatroomName,
       Identity identity)
Connects to a chatroom. 
 | 
com.google.android.gms.tasks.Task<Void> | 
disconnect()
Disconnect from current server. 
 | 
com.google.android.gms.tasks.Task<AggregatedData[]> | 
getAggregatedData(MessageRequest request)
Get aggregated-data history in this chatroom. 
 | 
ChatMode | 
getChatMode()
Returns  
ChatMode. | 
com.google.android.gms.tasks.Task<ChatroomInfo> | 
getChatroomInfo()
Gets  
ChatroomInfo of current chatroom. | 
ChatroomState | 
getChatroomState()
Returns current chatroom state. 
 | 
User | 
getCurrentUser()
Returns current user. 
 | 
com.google.android.gms.tasks.Task<Message[]> | 
getMessages(MessageRequest request)
Get Message history in this chatroom. 
 | 
com.google.android.gms.tasks.Task<androidx.collection.SimpleArrayMap<String,ChatMetadata>> | 
getMetadata(String... keys)
Gets the meta data from current chatroom. 
 | 
Message | 
getPinnedMessage()
Returns the pinned message in current chatroom. 
 | 
com.google.android.gms.tasks.Task<Message[]> | 
getRawData(MessageRequest request)
Get  
RawData history in this chatroom. | 
int | 
getSendMessageInterval()
Returns send message interval of current chatroom. 
 | 
List<Sticker> | 
getSticker()
Returns available stickers. 
 | 
androidx.collection.SimpleArrayMap<String,Integer> | 
getTotalAggregatedData()
Retrieve total aggregated data. 
 | 
int | 
getUserCount()
Returns current user count. 
 | 
com.google.android.gms.tasks.Task<User[]> | 
getUsers(UserType userType)
Gets users in this chatroom. 
 | 
static com.google.android.gms.tasks.Task<ChatroomManager> | 
initialize()
Constructs a  
ChatroomManager if you are a authorized developer. | 
static com.google.android.gms.tasks.Task<ChatroomManager> | 
initialize(ChatroomManager.ChatroomConfig config)
Constructs a  
ChatroomManager if you are a authorized developer. | 
com.google.android.gms.tasks.Task<Void> | 
pinMessage(Message message)
Pin a message to this chatroom, then everybody in this chatroom can get the pinned message by
  
getPinnedMessage() or EventListener.onPinnedMessageUpdated(Message). | 
void | 
removeAllEventListener()
Remove all event listener, no one could receive future event. 
 | 
boolean | 
removeEventListener(EventListener listener)  | 
com.google.android.gms.tasks.Task<Void> | 
removeMessage(Message message)
Remove message. 
 | 
boolean | 
resetIdentity(Identity identity)
Resets  
Identity. | 
com.google.android.gms.tasks.Task<Void> | 
reviveUsers(List<User> users)
Revive users from blocked status. 
 | 
com.google.android.gms.tasks.Task<Void> | 
sendAggregatedData(String message)
Send a string to chatroom which will be aggregated in  
onAggregatedDataAdded. | 
com.google.android.gms.tasks.Task<Void> | 
sendMessage(String message)
Sends message to chatroom. 
 | 
com.google.android.gms.tasks.Task<Void> | 
sendRawData(RawData rawData)
Send the  
RawData to chatroom. | 
com.google.android.gms.tasks.Task<Void> | 
setMetadata(String key,
           Object value,
           boolean broadcast)
Sets a set of meta data to current chatroom. 
 | 
com.google.android.gms.tasks.Task<Void> | 
unpinMessage()
Unpin the message from chatroom. 
 | 
com.google.android.gms.tasks.Task<Void> | 
updateNickname(String name)
Updates current user's nick name to server. 
 | 
com.google.android.gms.tasks.Task<Void> | 
updateUserRole(User user,
              Role role)
Update a user's role. 
 | 
com.google.android.gms.tasks.Task<Void> | 
updateUserRoleByMemberId(String memberId,
                        Role role)
Update a user's role by memberId. 
 | 
public static com.google.android.gms.tasks.Task<ChatroomManager> initialize()
ChatroomManager if you are a authorized developer.ChatroomManager if Task.isSuccessful().public static com.google.android.gms.tasks.Task<ChatroomManager> initialize(@NonNull ChatroomManager.ChatroomConfig config)
ChatroomManager if you are a authorized developer.config - configuration about the ChatroomManagerChatroomManager if Task.isSuccessful().public com.google.android.gms.tasks.Task<Void> connect(@NonNull String chatroomName, @NonNull Identity identity)
 This method should only be called when the chatroom state is ChatroomState.IDLE.
public boolean resetIdentity(Identity identity)
Identity. If you receive MessagingException.UnauthorizedException when the
 chatroom state is ChatroomState.CONNECTED, it means the member token in
 Identity is expired or invalid. Then, you can use this method to put new
 Identity in. Notice that the new Identity and the old Identity have
 to represent the same person.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
identity - New identity.public com.google.android.gms.tasks.Task<Message[]> getMessages(MessageRequest request)
MessageRequest.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
 request - request rule, see MessageRequestMessage if Task.isSuccessful().public com.google.android.gms.tasks.Task<AggregatedData[]> getAggregatedData(MessageRequest request)
MessageRequest.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
 request - request rule, see MessageRequestAggregatedData arrays if Task.isSuccessful().public com.google.android.gms.tasks.Task<Message[]> getRawData(MessageRequest request)
RawData history in this chatroom. You can set the request rule in MessageRequest.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
 request - request rule, see MessageRequestMessage if Task.isSuccessful().public com.google.android.gms.tasks.Task<User[]> getUsers(UserType userType)
Role.GLOBAL_MANAGER > Role.LOCAL_MANAGER > Role.MASTER >
 Role.MODERATOR > Role.NORMAL > Role.BLOCKED)] and user updated time.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
userType - decides who should be returnedUser if Task.isSuccessful().public com.google.android.gms.tasks.Task<ChatroomInfo> getChatroomInfo()
ChatroomInfo of current chatroom.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
ChatroomInfo if Task.isSuccessful().public com.google.android.gms.tasks.Task<Void> updateNickname(String name)
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a guest.
name - New nick name.public com.google.android.gms.tasks.Task<Void> updateUserRole(User user, Role role)
Role.NORMAL to
 Role.MODERATOR or from Role.MODERATOR to Role.NORMAL.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER.
user - the target userrole - new Rolepublic com.google.android.gms.tasks.Task<Void> updateUserRoleByMemberId(String memberId, Role role)
Role.NORMAL
 to Role.MODERATOR or from Role.MODERATOR to Role.NORMAL.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER.
memberId - the target user's member idrole - new Rolepublic com.google.android.gms.tasks.Task<Void> blockUsers(List<User> users)
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER, or Role.MODERATOR.
users - The target users.public com.google.android.gms.tasks.Task<Void> reviveUsers(List<User> users)
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER, or Role.MODERATOR.
users - The target users.public com.google.android.gms.tasks.Task<Void> removeMessage(Message message)
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER, or Role.MODERATOR.
message - The message to remove.public com.google.android.gms.tasks.Task<Void> sendMessage(String message)
MessagingException.PermissionException.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
message - message, should be within 500 characters and shouldn't be emptypublic com.google.android.gms.tasks.Task<Void> pinMessage(Message message)
getPinnedMessage() or EventListener.onPinnedMessageUpdated(Message). A
 chatroom can only have a pinned message at one time, it means this method will override the
 last pinned message.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER, or Role.MODERATOR.
message - the message you want to pinunpinMessage(), 
getPinnedMessage(), 
EventListener.onPinnedMessageUpdated(Message)public com.google.android.gms.tasks.Task<Void> unpinMessage()
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER, or Role.MODERATOR.
pinMessage(Message), 
getPinnedMessage(), 
EventListener.onPinnedMessageUpdated(Message)public com.google.android.gms.tasks.Task<Void> sendAggregatedData(String message)
onAggregatedDataAdded.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
message - A simple string, e.g. "like", "cry", should within 100 characters.public com.google.android.gms.tasks.Task<Void> sendRawData(@NonNull RawData rawData)
RawData to chatroom.
 This type of message will not be aggregated.
 This method should only be called when the chatroom state is ChatroomState.CONNECTED.
rawData - Use RawData.Builder to generate the JSON (RFC 7159) objectpublic void addFakeMessage(Message message)
public User getCurrentUser()
ChatroomState.CONNECTED, this
 method will return the cache of last connected user.public Message getPinnedMessage()
ChatroomState.CONNECTED, this method will return the cache of pinned message.pinMessage(Message), 
unpinMessage(), 
EventListener.onPinnedMessageUpdated(Message)public List<Sticker> getSticker()
ChatroomState.CONNECTED,
 this method will return cache of last connected chatroom's stickers.public int getUserCount()
ChatroomState.CONNECTED,
 this method will return the cache of last connected chatroom's user count.public ChatMode getChatMode()
ChatMode. If the chatroom state is not ChatroomState.CONNECTED,
 this method will return the cache of last connected chatroom's ChatMode.ChatMode.public int getSendMessageInterval()
ChatroomState.CONNECTED,
 this method will return the cache of last connected chatroom's send message interval.public ChatroomState getChatroomState()
ChatroomState.public com.google.android.gms.tasks.Task<Void> disconnect()
EventListener.onDisconnected() that was set in connect(String, Identity) will
 be invoked.
 
 This method should only be called when the chatroom state is ChatroomState.CONNECTED
 or ChatroomState.CONNECTING.
public boolean addEventListener(EventListener listener)
listener - Listens result of connection and other events.
                      See EventListener.public void addAllEventListener(EventListener... listeners)
listeners - Listens result of connection and other events.
                      See EventListener.public boolean removeEventListener(EventListener listener)
listener - Remove listener which doesn't want to receive future event.
                      See EventListener.public void removeAllEventListener()
EventListener.@NonNull public androidx.collection.SimpleArrayMap<String,Integer> getTotalAggregatedData()
public com.google.android.gms.tasks.Task<Void> setMetadata(@NonNull String key, @Nullable Object value, boolean broadcast)
ChatroomState.CONNECTED
 and the current user is a Role.GLOBAL_MANAGER, Role.LOCAL_MANAGER,
 Role.MASTER, or Role.MODERATOR.key - Corresponds to ChatMetadata.getKey(). Note that the key is unique of metadata
            in a chatroom. Key names start with _ are reserved, so these names are
            not supposed to be used. And the key must match regular expression ^[A-Za-z0-9][A-Za-z0-9_-@#]{0,29}$.value - Corresponds to ChatMetadata.getValue(). This will be converted to JSON (RFC 7159)
              type and the max size is 1k when broadcast is true and 4k when
              parameter broadcast is false.broadcast - Sets to true to broadcast this event, it means all users in this chatroom
                  will receive the change by EventListener.onMetadataUpdated(SimpleArrayMap).getMetadata(String[]), 
EventListener.onMetadataUpdated(SimpleArrayMap)public com.google.android.gms.tasks.Task<androidx.collection.SimpleArrayMap<String,ChatMetadata>> getMetadata(@Nullable String... keys)
ChatroomState.CONNECTED.keys - The keys of meta data you want to query. Key names start with _ are
             reserved, so these names are not supposed to be used. And the key must match
             regular expression ^[A-Za-z0-9][A-Za-z0-9_-@#]{0,29}$.
             Sets this to null will query all meta data of current chatroom.Task.isSuccessful()setMetadata(String, Object, boolean), 
ChatMetadata