hyphenate_SDK4.0 4.2.3-lite
hyphenate java IM SDK
Public Member Functions | List of all members
com.hyphenate.chat.EMChatRoomManager Class Reference

Public Member Functions

void addChatRoomChangeListener (EMChatRoomChangeListener listener)
 
void removeChatRoomListener (EMChatRoomChangeListener listener)
 
void joinChatRoom (final String roomId, final EMValueCallBack< EMChatRoom > callback)
 
void joinChatRoom (final String roomId, boolean leaveOtherRooms, String ext, final EMValueCallBack< EMChatRoom > callback)
 
void leaveChatRoom (final String roomId)
 
void leaveChatRoom (final String roomId, EMCallBack callback)
 
EMPageResult< EMChatRoomfetchPublicChatRoomsFromServer (int pageNum, int pageSize) throws HyphenateException
 
void asyncFetchPublicChatRoomsFromServer (final int pageNum, final int pageSize, final EMValueCallBack< EMPageResult< EMChatRoom > > callback)
 
EMChatRoom fetchChatRoomFromServer (String roomId) throws HyphenateException
 
EMChatRoom fetchChatRoomFromServer (String roomId, boolean fetchMembers) throws HyphenateException
 
void asyncFetchChatRoomFromServer (final String roomId, final EMValueCallBack< EMChatRoom > callback)
 
EMChatRoom getChatRoom (String roomId)
 
EMCursorResult< String > fetchChatRoomMembers (String chatRoomId, String cursor, int pageSize) throws HyphenateException
 
void asyncFetchChatRoomMembers (final String chatRoomId, final String cursor, final int pageSize, final EMValueCallBack< EMCursorResult< String > > callBack)
 
String fetchChatRoomAnnouncement (String chatRoomId) throws HyphenateException
 
void asyncFetchChatRoomAnnouncement (final String chatRoomId, final EMValueCallBack< 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:

EMClient.getInstance().chatroomManager().joinChatRoom(conversationId, new EMValueCallBack<EMChatRoom>() {
public void onSuccess(EMChatRoom 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

◆ addChatRoomChangeListener()

void com.hyphenate.chat.EMChatRoomManager.addChatRoomChangeListener ( EMChatRoomChangeListener  listener)

Adds a chat room event listener.

Note
Chat room destruction, member entry and exit, mute, and allow list changes among other chat room operations can be listened for by setting EMChatRoomChangeListener.

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

Parameters
listenerA chat room event listener. See EMChatRoomChangeListener.

◆ asyncFetchChatRoomAnnouncement()

void com.hyphenate.chat.EMChatRoomManager.asyncFetchChatRoomAnnouncement ( final String  chatRoomId,
final EMValueCallBack< 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 EMValueCallBack#onSuccess(Object) and returns the chat room announcement; if this call fails, calls EMValueCallBack#onError(int, String).

◆ asyncFetchChatRoomFromServer()

void com.hyphenate.chat.EMChatRoomManager.asyncFetchChatRoomFromServer ( final String  roomId,
final EMValueCallBack< EMChatRoom callback 
)

Gets details of a chat room from the server.

Note
This method does not get the chat room member list.

This is an asynchronous method.

For the synchronous method, see fetchChatRoomFromServer(String).

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

◆ asyncFetchChatRoomMembers()

void com.hyphenate.chat.EMChatRoomManager.asyncFetchChatRoomMembers ( final String  chatRoomId,
final String  cursor,
final int  pageSize,
final EMValueCallBack< EMCursorResult< String > >  callBack 
)

Gets the chat room member list.

Note
When EMCursorResult#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 start getting data. At the first call, if you set the cursor as "null", the SDK gets chat room members in the reverse chronological order of when members joined the chat room.
pageSizeThe number of members that you expect to get on each page. The value range is [1,50].
callBackThe completion callback. If this call succeeds, calls EMValueCallBack#onSuccess(Object); If this call fails, calls EMValueCallBack#onError(int, String).

◆ asyncFetchPublicChatRoomsFromServer()

void com.hyphenate.chat.EMChatRoomManager.asyncFetchPublicChatRoomsFromServer ( final int  pageNum,
final int  pageSize,
final EMValueCallBack< EMPageResult< EMChatRoom > >  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 that you expect to get on each page. The value range is [1,50].
callbackThe completion callback. If this call succeeds, calls EMValueCallBack#onSuccess(Object). If this call fails, calls EMValueCallBack#onError(int, String).

◆ fetchChatRoomAnnouncement()

String com.hyphenate.chat.EMChatRoomManager.fetchChatRoomAnnouncement ( String  chatRoomId) throws HyphenateException

Gets the chat room announcement from the server.

For the asynchronous method, see asyncFetchChatRoomAnnouncement(String, EMValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
Returns
The chat room announcement.
Exceptions
HyphenateExceptionA description of the exception. See EMError

◆ fetchChatRoomFromServer() [1/2]

EMChatRoom com.hyphenate.chat.EMChatRoomManager.fetchChatRoomFromServer ( String  roomId) throws HyphenateException

Gets details of a chat room from the server.

Note
This method does not get the member list.

This is a synchronous method and blocks the current thread.

For the asynchronous method, see asyncFetchChatRoomFromServer(String, EMValueCallBack).

Parameters
roomIdThe chat room ID.
Returns
EMChatRoom The chat room instance.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ fetchChatRoomFromServer() [2/2]

EMChatRoom com.hyphenate.chat.EMChatRoomManager.fetchChatRoomFromServer ( String  roomId,
boolean  fetchMembers 
) throws HyphenateException

Gets details of a chat room from the server.

Note
The member list, if required, can contain at most 200 members by default. For more members, call EMChatRoomManager#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
EMChatRoom The chat room instance.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ fetchChatRoomMembers()

EMCursorResult< String > com.hyphenate.chat.EMChatRoomManager.fetchChatRoomMembers ( String  chatRoomId,
String  cursor,
int  pageSize 
) throws HyphenateException

Gets the chat room member list.

Note
When EMCursorResult#getCursor() is an empty string ("") amid the result, all data is fetched.

For the asynchronous method, see asyncFetchChatRoomMembers(String, String, int, EMValueCallBack).

This is a synchronous method and blocks the current thread.

Parameters
chatRoomIdThe chat room ID.
cursorThe cursor position from which to start getting data. At the first call, if you set the cursor as "null", the SDK gets chat room members in the reverse chronological order of when members joined the chat room.
pageSizeThe number of members that you expect to get on each page. The value range is [1,50].
Returns
The list of chat room members and the cursor for the next query. See EMCursorResult.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ fetchPublicChatRoomsFromServer()

EMPageResult< EMChatRoom > com.hyphenate.chat.EMChatRoomManager.fetchPublicChatRoomsFromServer ( int  pageNum,
int  pageSize 
) throws HyphenateException

Gets chat room data from the server with pagination.

This is a synchronous method and blocks the current thread.

The asynchronous method asyncFetchPublicChatRoomsFromServer(int, int, EMValueCallBack) can be used.

Parameters
pageNumThe page number, starting from 1.
pageSizeThe number of records that you expect to get on each page. The value range is [1,50].
Returns
Chat room data. See EMPageResult.
Exceptions
HyphenateExceptionA description of the exception. See EMError.

◆ getChatRoom()

EMChatRoom com.hyphenate.chat.EMChatRoomManager.getChatRoom ( String  roomId)

Gets the chat room in the memory.

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

◆ joinChatRoom() [1/2]

void com.hyphenate.chat.EMChatRoomManager.joinChatRoom ( final String  roomId,
boolean  leaveOtherRooms,
String  ext,
final EMValueCallBack< EMChatRoom callback 
)

Joins a chat room.

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

This is an asynchronous method.

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

◆ joinChatRoom() [2/2]

void com.hyphenate.chat.EMChatRoomManager.joinChatRoom ( final String  roomId,
final EMValueCallBack< EMChatRoom callback 
)

Joins a chat room.

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

This is an asynchronous method.

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

◆ leaveChatRoom() [1/2]

void com.hyphenate.chat.EMChatRoomManager.leaveChatRoom ( final String  roomId)

Exits a chat room.

Note
A user that joins a chat room using joinChatRoom(String, EMValueCallBack) can call the leaveChatRoom method to exit the chat room.

This is an asynchronous method.

Parameters
roomIdThe ID of the chat room to exit.

◆ leaveChatRoom() [2/2]

void com.hyphenate.chat.EMChatRoomManager.leaveChatRoom ( final String  roomId,
EMCallBack  callback 
)

Exits a chat room.

A user that joins a chat room using joinChatRoom(String, EMValueCallBack) can call the leaveChatRoom method to exit the chat room.

This is an asynchronous method.

Parameters
roomIdThe ID of the chat room to exit.
callbackThe completion callback. If this call succeeds, calls EMCallBack#onSuccess(); if this call fails, calls EMCallBack#onError(int, String).

◆ removeChatRoomListener()

void com.hyphenate.chat.EMChatRoomManager.removeChatRoomListener ( EMChatRoomChangeListener  listener)

Removes the chat room event listener.

Note
This method removes the chat room event listener added with addChatRoomChangeListener(EMChatRoomChangeListener).
Parameters
listenerThe chat room event listener to be removed.

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