agora_chat_SDK 1.0.6
agora java chat SDK
Public Member Functions | List of all members
io.agora.chat.ChatRoomManager Class Reference

Public Member Functions

 ChatRoomManager (ChatClient client, EMAChatRoomManager manager)
 
void addChatRoomChangeListener (ChatRoomChangeListener listener)
 
void removeChatRoomChangeListener (ChatRoomChangeListener listener)
 
void removeChatRoomListener (ChatRoomChangeListener listener)
 
void joinChatRoom (final String roomId, final ValueCallBack< ChatRoom > callback)
 
void leaveChatRoom (final String roomId)
 
PageResult< ChatRoomfetchPublicChatRoomsFromServer (int pageNum, int pageSize) throws ChatException
 
CursorResult< ChatRoomfetchPublicChatRoomsFromServer (int pageSize, String cursor) throws ChatException
 
void asyncFetchPublicChatRoomsFromServer (final int pageSize, final String cursor, final ValueCallBack< CursorResult< ChatRoom > > callback)
 
void asyncFetchPublicChatRoomsFromServer (final int pageNum, final int pageSize, final ValueCallBack< PageResult< ChatRoom > > callback)
 
ChatRoom fetchChatRoomFromServer (String roomId) throws ChatException
 
ChatRoom fetchChatRoomFromServer (String roomId, boolean fetchMembers) throws ChatException
 
void asyncFetchChatRoomFromServer (final String roomId, final ValueCallBack< ChatRoom > callback)
 
ChatRoom getChatRoom (String roomId)
 
List< ChatRoomgetAllChatRooms ()
 
ChatRoom createChatRoom (String subject, String description, String welcomeMessage, int maxUserCount, List< String > members) throws ChatException
 
void asyncCreateChatRoom (final String subject, final String description, final String welcomeMessage, final int maxUserCount, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
void destroyChatRoom (String chatRoomId) throws ChatException
 
void asyncDestroyChatRoom (final String chatRoomId, final CallBack callBack)
 
ChatRoom changeChatRoomSubject (String chatRoomId, String newSubject) throws ChatException
 
void asyncChangeChatRoomSubject (final String chatRoomId, final String newSubject, final ValueCallBack< ChatRoom > callBack)
 
ChatRoom changeChatroomDescription (String chatRoomId, String newDescription) throws ChatException
 
void asyncChangeChatroomDescription (final String chatRoomId, final String newDescription, final ValueCallBack< ChatRoom > callBack)
 
CursorResult< String > fetchChatRoomMembers (String chatRoomId, String cursor, int pageSize) throws ChatException
 
void asyncFetchChatRoomMembers (final String chatRoomId, final String cursor, final int pageSize, final ValueCallBack< CursorResult< String > > callBack)
 
ChatRoom muteChatRoomMembers (String chatRoomId, List< String > muteMembers, long duration) throws ChatException
 
void asyncMuteChatRoomMembers (final String chatRoomId, final List< String > muteMembers, final long duration, final ValueCallBack< ChatRoom > callBack)
 
ChatRoom unMuteChatRoomMembers (String chatRoomId, List< String > members) throws ChatException
 
void asyncUnMuteChatRoomMembers (final String chatRoomId, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
ChatRoom changeOwner (String chatRoomId, String newOwner) throws ChatException
 
void asyncChangeOwner (final String chatRoomId, final String newOwner, final ValueCallBack< ChatRoom > callBack) throws ChatException
 
ChatRoom addChatRoomAdmin (String chatRoomId, String admin) throws ChatException
 
void asyncAddChatRoomAdmin (final String chatRoomId, final String admin, final ValueCallBack< ChatRoom > callBack)
 
ChatRoom removeChatRoomAdmin (String chatRoomId, String admin) throws ChatException
 
void asyncRemoveChatRoomAdmin (final String chatRoomId, final String admin, final ValueCallBack< ChatRoom > callBack)
 
Map< String, Long > fetchChatRoomMuteList (String chatRoomId, int pageNum, int pageSize) throws ChatException
 
void asyncFetchChatRoomMuteList (final String chatRoomId, final int pageNum, final int pageSize, final ValueCallBack< Map< String, Long > > callBack)
 
ChatRoom removeChatRoomMembers (String chatRoomId, List< String > members) throws ChatException
 
void asyncRemoveChatRoomMembers (final String chatRoomId, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
ChatRoom blockChatroomMembers (String chatRoomId, List< String > members) throws ChatException
 
void asyncBlockChatroomMembers (final String chatRoomId, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
ChatRoom unblockChatRoomMembers (String chatRoomId, List< String > members) throws ChatException
 
void asyncUnBlockChatRoomMembers (final String chatRoomId, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
List< String > fetchChatRoomBlackList (String chatRoomId, int pageNum, int pageSize) throws ChatException
 
void asyncFetchChatRoomBlackList (final String chatRoomId, final int pageNum, final int pageSize, final ValueCallBack< List< String > > callBack)
 
void addToChatRoomWhiteList (final String chatRoomId, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
void removeFromChatRoomWhiteList (final String chatRoomId, final List< String > members, final ValueCallBack< ChatRoom > callBack)
 
void checkIfInChatRoomWhiteList (final String chatRoomId, ValueCallBack< Boolean > callBack)
 
void fetchChatRoomWhiteList (final String chatRoomId, final ValueCallBack< List< String > > callBack)
 
void muteAllMembers (final String chatRoomId, final ValueCallBack< ChatRoom > callBack)
 
void unmuteAllMembers (final String chatRoomId, final ValueCallBack< ChatRoom > callBack)
 
void updateChatRoomAnnouncement (String chatRoomId, String announcement) throws ChatException
 
void asyncUpdateChatRoomAnnouncement (final String chatRoomId, final String announcement, final CallBack callBack)
 
String fetchChatRoomAnnouncement (String chatRoomId) throws ChatException
 
void asyncFetchChatRoomAnnouncement (final String chatRoomId, final ValueCallBack< String > callBack)
 

Detailed Description

The chat room manager, which manages users joining and existing the chat room and getting the chat room list, and manages member privileges. For example, joining a chat room:

ChatClient.getInstance().chatroomManager().joinChatRoom(conversationId, new ValueCallBack<ChatRoom>() {
public void onSuccess(ChatRoom value) {
//Processing logic for successful chat room joining.
}
public void onError(int error, String errorMsg) {
//Processing logic for chat room joining failures.
}
});

Member Function Documentation

◆ addChatRoomAdmin()

ChatRoom io.agora.chat.ChatRoomManager.addChatRoomAdmin ( String  chatRoomId,
String  admin 
) throws ChatException

Adds a chat room admin. Only the chat room owner can call this method. For the asynchronous method, see asyncAddChatRoomAdmin(String, String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
adminThe ID of the chat room admin to be added.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ addChatRoomChangeListener()

void io.agora.chat.ChatRoomManager.addChatRoomChangeListener ( ChatRoomChangeListener  listener)

Registers a chat room event listener. Chat room destruction, member entry and exit, mute, and allowlist entry addition among other operations can be listened by setting ChatRoomChangeListener.

Chat room event listeners registered with this method can be removed by calling removeChatRoomListener(ChatRoomChangeListener).

Parameters
listenerA chat room listener. See ChatRoomChangeListener.

◆ addToChatRoomWhiteList()

void io.agora.chat.ChatRoomManager.addToChatRoomWhiteList ( final String  chatRoomId,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Adds members to the allowlist. Only the chat room owner or admin can call this method. For members added to the allowlist, muteAllMembers(String, ValueCallBack), when executed by the chat room owner or admin, does not work.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be added to the allowlist.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncAddChatRoomAdmin()

void io.agora.chat.ChatRoomManager.asyncAddChatRoomAdmin ( final String  chatRoomId,
final String  admin,
final ValueCallBack< ChatRoom callBack 
)

Adds a chat room admin. Only the chat room owner can call this method. For the asynchronous method, see addChatRoomAdmin(String, String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
adminThe ID of the chat room admin to be added.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncBlockChatroomMembers()

void io.agora.chat.ChatRoomManager.asyncBlockChatroomMembers ( final String  chatRoomId,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Adds members to the chat room's blocklist. Only the chat room owner or admin can call this method. For members added to blacklist, note the following:

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be added to blocklist.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); If this call fails, calls ValueCallBack#onError(int, String).

◆ asyncChangeChatroomDescription()

void io.agora.chat.ChatRoomManager.asyncChangeChatroomDescription ( final String  chatRoomId,
final String  newDescription,
final ValueCallBack< ChatRoom callBack 
)

Modifies the chat room description. Only the chat room owner can call this method. For the synchronous method, see changeChatroomDescription(String, String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
newDescriptionThe new description of the chat room.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncChangeChatRoomSubject()

void io.agora.chat.ChatRoomManager.asyncChangeChatRoomSubject ( final String  chatRoomId,
final String  newSubject,
final ValueCallBack< ChatRoom callBack 
)

Changes the chat room subject. Only the chat room owner can call this method. For the synchronous method, see changeChatRoomSubject(String, String).

This is an asynchronous method.

Parameters
chatRoomIdA chat room ID.
newSubjectThe new subject of the chat room.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncChangeOwner()

void io.agora.chat.ChatRoomManager.asyncChangeOwner ( final String  chatRoomId,
final String  newOwner,
final ValueCallBack< ChatRoom callBack 
) throws ChatException

Transfers the chat room ownership. Only the chat room owner can call this method. For the synchronous method, see changeOwner(String, String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
newOwnerThe ID of the new chat room owner.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncCreateChatRoom()

void io.agora.chat.ChatRoomManager.asyncCreateChatRoom ( final String  subject,
final String  description,
final String  welcomeMessage,
final int  maxUserCount,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Creates a chat room. For the synchronous method, see createChatRoom(String, String, String, int, List).

This is an asynchronous method.

Parameters
subjectThe chat room subject.
descriptionThe chat room description.
welcomeMessageA welcome message inviting members to join the chat room.
maxUserCountThe maximum number of members allowed to join the chat room.
membersThe list of members invited to join the chat room.
callBackThe completion callback. If this call succeeds calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncDestroyChatRoom()

void io.agora.chat.ChatRoomManager.asyncDestroyChatRoom ( final String  chatRoomId,
final CallBack  callBack 
)

Destroys a chat room. Only the chat room owner can call this method. For the synchronous method, see destroyChatRoom(String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
callBackThe completion callback. If this call succeeds, calls CallBack#onSuccess(); if this call fails, calls CallBack#onError(int, String).

◆ asyncFetchChatRoomAnnouncement()

void io.agora.chat.ChatRoomManager.asyncFetchChatRoomAnnouncement ( final String  chatRoomId,
final ValueCallBack< String >  callBack 
)

Gets the chat room announcement from the server. For the synchronous method, see fetchChatRoomAnnouncement(String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object) and returns the chat room announcement; if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncFetchChatRoomBlackList()

void io.agora.chat.ChatRoomManager.asyncFetchChatRoomBlackList ( final String  chatRoomId,
final int  pageNum,
final int  pageSize,
final ValueCallBack< List< String > >  callBack 
)

Gets the chat room blocklist with pagination. Only the chat room owner or admin can call this method. For the synchronous method, see fetchChatRoomBlackList(String, int, int).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
pageNumThe page number, starting from 1.
pageSizeThe number of users on the blocklist per page.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object) and returns the chat room's blocklist; If this call fails, calls ValueCallBack#onError(int, String). Note the following:
  • pageSize specifies the number of records expected to return for this call. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • pageNum specifies the number of the current page on which the returned data is presented. For a large but unknown quantity of data, the server will return data as specified by pageSize and pageNum.

◆ asyncFetchChatRoomFromServer()

void io.agora.chat.ChatRoomManager.asyncFetchChatRoomFromServer ( final String  roomId,
final ValueCallBack< ChatRoom callback 
)

Gets details of a chat room from the server, excluding the member list by default. For the synchronous method, see fetchChatRoomFromServer(String).

This is an asynchronous method.

Parameters
roomIdThe chat room ID.
callbackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, callsValueCallBack#onError(int, String).

◆ asyncFetchChatRoomMembers()

void io.agora.chat.ChatRoomManager.asyncFetchChatRoomMembers ( final String  chatRoomId,
final String  cursor,
final int  pageSize,
final ValueCallBack< CursorResult< String > >  callBack 
)

Gets the chat room member list. When CursorResult.getCursor() is an empty string ("") amid the result, all data is fetched.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
cursorThe cursor position from which to get data.
pageSizeThe number of members per page.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); If this call fails, calls ValueCallBack#onError(int, String). Note the following:
  • One page of data is returned each time this method is called. During the first call to this method, null is passed to cursor and the latest records are returned. Amid the returned data, cursor is a field saved locally and the updated parameter will be passed to be the position from which to obtain data.
  • pageSize specifies the number of the current page on which the returned data is presented. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • For a large but unknown quantity of data, the server will return data as specified by pageSize and the cursor.

◆ asyncFetchChatRoomMuteList()

void io.agora.chat.ChatRoomManager.asyncFetchChatRoomMuteList ( final String  chatRoomId,
final int  pageNum,
final int  pageSize,
final ValueCallBack< Map< String, Long > >  callBack 
)

Gets the list of members who are muted in the chat room from the server. Only the chat room owner or admin can call this method. For the synchronous method, see fetchChatRoomMuteList(String, int, int).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
pageNumThe page number, starting from 1.
pageSizeThe number of muted members per page.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); If this call fails, calls ValueCallBack#onError(int, String). Note the following:
  • pageSize specifies the number of muted members expected to return for this call. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • pageNum specifies the number of the current page on which the returned data is presented. For a large but unknown quantity of data, the server will return data as specified by pageSize and pageNum.

◆ asyncFetchPublicChatRoomsFromServer() [1/2]

void io.agora.chat.ChatRoomManager.asyncFetchPublicChatRoomsFromServer ( final int  pageNum,
final int  pageSize,
final ValueCallBack< PageResult< ChatRoom > >  callback 
)

Gets chat room data from the server with pagination.

This is an asynchronous method.

Parameters
pageNumThe page number, starting from 1.
pageSizeThe number of records per page.
callbackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object). If this call fails, calls ValueCallBack#onError(int, String). Note the following:
  • pageSize specifies the number of records expected to return for this call. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • pageNum specifies the number of the current page on which the returned data is presented. For a large but unknown quantity of data, the server will return data with pagination as specified by pageSize and pageNum.

◆ asyncFetchPublicChatRoomsFromServer() [2/2]

void io.agora.chat.ChatRoomManager.asyncFetchPublicChatRoomsFromServer ( final int  pageSize,
final String  cursor,
final ValueCallBack< CursorResult< ChatRoom > >  callback 
)

Gets chat room data from the server with pagination. When CursorResult.getCursor() is an empty string ("") amid the result, all data is fetched.

This is an asynchronous method.

Parameters
pageSizeThe number of records per page.
cursorThe cursor position from which to start getting data.
callbackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); If this call fails, calls ValueCallBack#onError(int, String).
Deprecated:
Deprecated. Please use asyncFetchPublicChatRoomsFromServer(int, int, ValueCallBack) instead.

◆ asyncMuteChatRoomMembers()

void io.agora.chat.ChatRoomManager.asyncMuteChatRoomMembers ( final String  chatRoomId,
final List< String >  muteMembers,
final long  duration,
final ValueCallBack< ChatRoom callBack 
)

Mutes members in a chat room. Only the chat room owner or admin can call this method. For the synchronous method, see muteChatRoomMembers(String, List, long).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
muteMembersThe list of members to be muted.
durationThe mute duration in milliseconds.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncRemoveChatRoomAdmin()

void io.agora.chat.ChatRoomManager.asyncRemoveChatRoomAdmin ( final String  chatRoomId,
final String  admin,
final ValueCallBack< ChatRoom callBack 
)

Removes the privileges of a chat room admin. Only the chat room owner can call this method. For the synchronous method, see removeChatRoomAdmin(String, String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
adminThe ID of admin whose privileges are to be removed.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncRemoveChatRoomMembers()

void io.agora.chat.ChatRoomManager.asyncRemoveChatRoomMembers ( final String  chatRoomId,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Removes members from a chat room. Only the chat room owner or admin can call this method. For the synchronous method, see removeChatRoomMembers(String, List).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be removed.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncUnBlockChatRoomMembers()

void io.agora.chat.ChatRoomManager.asyncUnBlockChatRoomMembers ( final String  chatRoomId,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Removes members from the chat room's blocklist. Only the chat room owner or admin can call this method. For the synchronous method, see unblockChatRoomMembers(String, List).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be removed from the blocklist.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncUnMuteChatRoomMembers()

void io.agora.chat.ChatRoomManager.asyncUnMuteChatRoomMembers ( final String  chatRoomId,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Unmutes members in a chat room. Only the chat room owner or admin can call this method. For the synchronous method, see unMuteChatRoomMembers(String, List).

This is an asynchronous method.

Parameters
chatRoomIdA chat room ID.
membersThe list of members to be unmuted.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ asyncUpdateChatRoomAnnouncement()

void io.agora.chat.ChatRoomManager.asyncUpdateChatRoomAnnouncement ( final String  chatRoomId,
final String  announcement,
final CallBack  callBack 
)

Updates the chat room announcement. Only the chat room owner or admin can call this method. For the synchronous method, see updateChatRoomAnnouncement(String, String).

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID
announcementThe announcement content.
callBackThe completion callback. If this call succeeds, calls CallBack#onSuccess(); if this call fails, calls CallBack#onError(int, String).

◆ blockChatroomMembers()

ChatRoom io.agora.chat.ChatRoomManager.blockChatroomMembers ( String  chatRoomId,
List< String >  members 
) throws ChatException

Adds members to the chat room's blocklist. Only the chat room owner or admin can call this method. For members added to blocklist, note the following:

  1. A member, once added to the chat room blocklist, will be removed from the chat room by the server.
  2. The method ChatRoomChangeListener#onRemovedFromChatRoom(int, String, String, String) occurs, where the first parameter is the reason which is EMAChatRoomManagerListener#BE_KICKED.
  3. Members added to the blocklist are banned from rejoining the chat room. For the asynchronous method, see asyncBlockChatroomMembers(String, List, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be added to blocklist.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ changeChatroomDescription()

ChatRoom io.agora.chat.ChatRoomManager.changeChatroomDescription ( String  chatRoomId,
String  newDescription 
) throws ChatException

Modifies the chat room description. Only the chat room owner can call this method. For the asynchronous method, see asyncChangeChatroomDescription(String, String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
newDescriptionThe new description of the chat room.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ changeChatRoomSubject()

ChatRoom io.agora.chat.ChatRoomManager.changeChatRoomSubject ( String  chatRoomId,
String  newSubject 
) throws ChatException

Changes the chat room subject. Only the chat room owner can call this method. For the asynchronous method, see asyncChangeChatRoomSubject(String, String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
newSubjectThe new subject of the chat room.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error

◆ changeOwner()

ChatRoom io.agora.chat.ChatRoomManager.changeOwner ( String  chatRoomId,
String  newOwner 
) throws ChatException

Transfers the chat room ownership. Only the chat room owner can call this method. For the asynchronous method, see asyncChangeOwner(String, String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdA chat room ID.
newOwnerThe ID of the new chat room owner.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ checkIfInChatRoomWhiteList()

void io.agora.chat.ChatRoomManager.checkIfInChatRoomWhiteList ( final String  chatRoomId,
ValueCallBack< Boolean >  callBack 
)

Checks whether the member is on the blocklist.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object) to show whether the member is on the blocklist; if this call fails, calls ValueCallBack#onError(int, String).

◆ createChatRoom()

ChatRoom io.agora.chat.ChatRoomManager.createChatRoom ( String  subject,
String  description,
String  welcomeMessage,
int  maxUserCount,
List< String >  members 
) throws ChatException

Creates a chat room. For the asynchronous method, see asyncCreateChatRoom(String, String, String, int, List, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
subjectThe chat room subject.
descriptionThe chat room description.
welcomeMessageA welcome message inviting members to join the chat room.
maxUserCountThe maximum number of members allowed to join the chat room.
membersThe list of members invited to join the chat room.
Returns
ChatRoom The chat room instance created successfully.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ destroyChatRoom()

void io.agora.chat.ChatRoomManager.destroyChatRoom ( String  chatRoomId) throws ChatException

Destroys a chat room. Only the chat room owner can call this method. For the asynchronous method, see asyncDestroyChatRoom(String, CallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ fetchChatRoomAnnouncement()

String io.agora.chat.ChatRoomManager.fetchChatRoomAnnouncement ( String  chatRoomId) throws ChatException

Gets the chat room announcement from the server. For the asynchronous method, see asyncFetchChatRoomAnnouncement(String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
Returns
The chat room announcement.
Exceptions
ChatExceptionA description of the exception. See Error

◆ fetchChatRoomBlackList()

List< String > io.agora.chat.ChatRoomManager.fetchChatRoomBlackList ( String  chatRoomId,
int  pageNum,
int  pageSize 
) throws ChatException

Gets the chat room blocklist with pagination. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncFetchChatRoomBlackList(String, int, int, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
pageNumThe page number, starting from 1.
pageSizeThe number of users on the blocklist per page.
Returns
The chat room's blocklist.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

Note the following:

  • pageSize specifies the number of records expected to return for this call. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • pageNum specifies the number of the current page on which the returned data is presented. For a large but unknown quantity of data, the server will return data as specified by pageSize and pageNum.

◆ fetchChatRoomFromServer() [1/2]

ChatRoom io.agora.chat.ChatRoomManager.fetchChatRoomFromServer ( String  roomId) throws ChatException

Gets details of a chat room from the server, excluding the member list by default. For the asynchronous method, see asyncFetchChatRoomFromServer(String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
roomIdThe chat room ID.
Returns
ChatRoom The chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ fetchChatRoomFromServer() [2/2]

ChatRoom io.agora.chat.ChatRoomManager.fetchChatRoomFromServer ( String  roomId,
boolean  fetchMembers 
) throws ChatException

Gets details of a chat room from the server. The member list, if required, can contain at most 200 members by default. For more members, call ChatRoomManager#fetchChatRoomMembers(String, String, int).

This is a synchronous method and blocks the current thread.

Parameters
roomIdThe chat room ID.
fetchMembersWhether to get chat room members.
Returns
ChatRoom The chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ fetchChatRoomMembers()

CursorResult< String > io.agora.chat.ChatRoomManager.fetchChatRoomMembers ( String  chatRoomId,
String  cursor,
int  pageSize 
) throws ChatException

Gets the chat room member list. When CursorResult.getCursor() is an empty string ("") amid the result, all data is fetched. For the asynchronous method, see asyncFetchChatRoomMembers(String, String, int, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
cursorThe cursor position from which to start getting data.
pageSizeThe number of members per page.
Returns
The list of chat room members. See CursorResult.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error. Note the following:
  • One page of data is returned each time this method is called. During the first call to this method, null is passed to cursor and the latest records are returned. Amid the returned data, cursor is a field saved locally and the updated parameter will be passed to be the position from which to obtain data.
  • pageSize specifies the number of the current page on which the returned data is presented. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • For a large but unknown quantity of data, the server will return data as specified by pageSize and the cursor.

◆ fetchChatRoomMuteList()

Map< String, Long > io.agora.chat.ChatRoomManager.fetchChatRoomMuteList ( String  chatRoomId,
int  pageNum,
int  pageSize 
) throws ChatException

Gets the list of members who are muted in the chat room from the server. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncFetchChatRoomMuteList(String, int, int, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID
pageNumThe page number, starting from 1.
pageSizeThe number of muted members per page.
Returns
A map which contains the muted member ID and mute duration, where the key of each entry is the ID of a muted member and the value is the mute duration in milliseconds.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error Note the following:
  • pageSize specifies the number of muted members expected to return for this call. For the last page, the actual number of returned records is no greater than the value of pageSize.
  • pageNum specifies the number of the current page on which the returned data is presented. For a large but unknown quantity of data, the server will return data as specified by pageSize and pageNum.

◆ fetchChatRoomWhiteList()

void io.agora.chat.ChatRoomManager.fetchChatRoomWhiteList ( final String  chatRoomId,
final ValueCallBack< List< String > >  callBack 
)

Gets the blocklist from the server. Only the chat room owner or admin can call this method.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); If this call fails, calls ValueCallBack#onError(int, String).

◆ fetchPublicChatRoomsFromServer() [1/2]

PageResult< ChatRoom > io.agora.chat.ChatRoomManager.fetchPublicChatRoomsFromServer ( int  pageNum,
int  pageSize 
) throws ChatException

Gets chat room data from the server with pagination. This is a synchronous method. Also, the asynchronous method asyncFetchPublicChatRoomsFromServer(int, int, ValueCallBack) can be used.

This is a synchronous method and blocks the current thread.

Parameters
pageNumThe page number, starting from 1.
pageSizeThe number of records per page.
Returns
Chat room data. See PageResult.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

Note the following:

  • pageSize specifies the number of records expected to return for this call. For the last page, the actual number of returned records is less than the value of pageSize.
  • pageNum specifies the number of the current page on which the returned data is presented. For a large but unknown quantity of data, the server will return data with pagination as specified by pageSize and pageNum.

◆ fetchPublicChatRoomsFromServer() [2/2]

CursorResult< ChatRoom > io.agora.chat.ChatRoomManager.fetchPublicChatRoomsFromServer ( int  pageSize,
String  cursor 
) throws ChatException

Gets chat room data from the server with pagination. When CursorResult.getCursor() is an empty string ("") amid the result, all data is fetched. As this method is time-consuming, the asynchronous method asyncFetchPublicChatRoomsFromServer(int, String, ValueCallBack) can be used.

This is a synchronous method and blocks the current thread.

Parameters
pageSizeThe number of records per page.
cursorThe cursor position from which to start getting data.
Returns
Chat room data. See CursorResult.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.
Deprecated:
Deprecated. Please use fetchPublicChatRoomsFromServer(int, int) instead.

◆ getAllChatRooms()

List< ChatRoom > io.agora.chat.ChatRoomManager.getAllChatRooms ( )

Gets the list of chat rooms in the cache. Note: Data can be returned upon the call of this method only after one of the following methods is called:

◆ getChatRoom()

ChatRoom io.agora.chat.ChatRoomManager.getChatRoom ( String  roomId)

Gets the chat room in the cache.

Parameters
roomIdThe chat room ID.
Returns
The chat room instance. Returns null if the chat room is not found in the cache.

◆ joinChatRoom()

void io.agora.chat.ChatRoomManager.joinChatRoom ( final String  roomId,
final ValueCallBack< ChatRoom callback 
)

Joins the chat room. To exit the chat room, call leaveChatRoom(String).

This is an asynchronous method.

Parameters
roomIdThe ID of the chat room to join.
callbackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object) and returns the chat room object; if this call fails, calls ValueCallBack#onError(int, String), where the first parameter is the error code and the second is the error message.

◆ leaveChatRoom()

void io.agora.chat.ChatRoomManager.leaveChatRoom ( final String  roomId)

Leaves a chat room. This method is called for a member to leave a chat room the members joins using joinChatRoom(String, ValueCallBack).

This is an asynchronous method.

Parameters
roomIdThe ID of the chat room to leave.

◆ muteAllMembers()

void io.agora.chat.ChatRoomManager.muteAllMembers ( final String  chatRoomId,
final ValueCallBack< ChatRoom callBack 
)

Mutes all members. Only the chat room owner or admin can call this method. This method does not work for the chat room owner, admin, and members added to the blocklist.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ muteChatRoomMembers()

ChatRoom io.agora.chat.ChatRoomManager.muteChatRoomMembers ( String  chatRoomId,
List< String >  muteMembers,
long  duration 
) throws ChatException

Mutes members in a chat room. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncMuteChatRoomMembers(String, List, long, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
muteMembersThe list of members to be muted.
durationThe mute duration in milliseconds.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ removeChatRoomAdmin()

ChatRoom io.agora.chat.ChatRoomManager.removeChatRoomAdmin ( String  chatRoomId,
String  admin 
) throws ChatException

Removes privileges of a chat room admin. Only the chat room owner can call this method. For the asynchronous method, see asyncRemoveChatRoomAdmin(String, String, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
adminThe ID of admin whose privileges are to be removed.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ removeChatRoomChangeListener()

void io.agora.chat.ChatRoomManager.removeChatRoomChangeListener ( ChatRoomChangeListener  listener)

Removes a chat room event listener. This method removes a chat room event listener registered with addChatRoomChangeListener(ChatRoomChangeListener). Currently, removeChatRoomListener(ChatRoomChangeListener) is recommended to remove a chat room event listener.

Parameters
listenerThe chat room listener to be removed.
Deprecated:
Deprecated. Please use ChatRoomManager#removeChatRoomListener(ChatRoomChangeListener) instead.

◆ removeChatRoomListener()

void io.agora.chat.ChatRoomManager.removeChatRoomListener ( ChatRoomChangeListener  listener)

Removes the chat room event listener. This method removes the chat room event listener registered with addChatRoomChangeListener(ChatRoomChangeListener).

Parameters
listenerThe chat room event listener to be removed.

◆ removeChatRoomMembers()

ChatRoom io.agora.chat.ChatRoomManager.removeChatRoomMembers ( String  chatRoomId,
List< String >  members 
) throws ChatException

Removes members from a chat room. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncRemoveChatRoomMembers(String, List, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be removed.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ removeFromChatRoomWhiteList()

void io.agora.chat.ChatRoomManager.removeFromChatRoomWhiteList ( final String  chatRoomId,
final List< String >  members,
final ValueCallBack< ChatRoom callBack 
)

Removes members from the blocklist. Only the chat room owner or admin can call this method. For members removed from the blocklist, muteAllMembers(String, ValueCallBack) works.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be removed from the blocklist.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); if this call fails, calls ValueCallBack#onError(int, String).

◆ unblockChatRoomMembers()

ChatRoom io.agora.chat.ChatRoomManager.unblockChatRoomMembers ( String  chatRoomId,
List< String >  members 
) throws ChatException

Removes members from the chat room's blocklist. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncBlockChatroomMembers(String, List, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be removed from the blocklist.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ unmuteAllMembers()

void io.agora.chat.ChatRoomManager.unmuteAllMembers ( final String  chatRoomId,
final ValueCallBack< ChatRoom callBack 
)

Unmutes all members. Only the chat room owner or admin can call this method.

This is an asynchronous method.

Parameters
chatRoomIdThe chat room ID.
callBackThe completion callback. If this call succeeds, calls ValueCallBack#onSuccess(Object); If this call fails, calls ValueCallBack#onError(int, String).

◆ unMuteChatRoomMembers()

ChatRoom io.agora.chat.ChatRoomManager.unMuteChatRoomMembers ( String  chatRoomId,
List< String >  members 
) throws ChatException

Unmutes members in a chat room. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncUnMuteChatRoomMembers(String, List, ValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
membersThe list of members to be unmuted.
Returns
The modified chat room instance.
Exceptions
ChatExceptionA description of the exception. See io.agora.Error.

◆ updateChatRoomAnnouncement()

void io.agora.chat.ChatRoomManager.updateChatRoomAnnouncement ( String  chatRoomId,
String  announcement 
) throws ChatException

Updates the chat room announcement. Only the chat room owner or admin can call this method. For the asynchronous method, see asyncUpdateChatRoomAnnouncement(String, String, CallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
announcementThe announcement content.
Exceptions
ChatExceptionA description of the exception. See Error.

The documentation for this class was generated from the following file: