Chatroom Management

This section introduces a chatroom management function in Hummer ChatRoom SDK.

1. Introduction

This SDK provides a chatroom management method to satisfy the needs of your different application scenarios.

2. Implementation

Get Chatroom Members

In some scenarios, a single chatroom may have many thousands of members; therefore, this SDK provides corresponding paged member lists according to your requirements. Meanwhile, a corresponding member list is sorted according to certain default rules. You can use the API for retrieving the member list even without entering the chatroom. Call fetchMembers to search for the member in the chatroom.

// chatRoom  Chatroom ID of members to be acquired
// num  Number of members to be acquired
// offset  Position to be fetched, starting from 0 on page 1
// completion  Callback upon acquisition; services may process it differently according to the corresponding acquisition result; after successful acquisition, service may process through the successful member list
HMR.getService(ChatRoomService.class).fetchMembers(ChatRoom chatRoom, int num, int offset, new HMR.CompletionArg<List<User>>() {
    @Override
    public void onSuccess(List<User> arg) {

    }

    @Override
    public void onFailed(Error err) {

    }
});

Remove Chatroom Members

Only certain roles (Admin and Owner) can remove chatroom members. Though Admin roles cannot remove other Admin and Owner roles, Owner roles can remove any members in the channel. Removed members (or members to be removed) must first join the channel for the removal to be effected. Call kick to remove members in the chatroom.

// chatRoom  ID of the chatroom where the member to be removed is
// member  ID of the member to be removed
// extraIno  Information carried by the member who is removed, in which the time limit and reason for removal may be included; this information will be passed-through to the business server via background
// completion  Callback upon moreval; services may process  it differently according to the corresponding removal result, and the reason for the corresponding error will also be carried if removal fails
HMR.getService(ChatRoomService.class).kick(ChatRoom chatRoom, User member, null, new HMR.Completion() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onFailed(Error err) {

    }
});

Mute Chatroom Members

The service can mute a specific member according to your requirement; however, the default muting time is three days, and there is no notification for unmuting after the three days. Only an Admin or Owner can enable mute. While an Admin can only mute regular members, an Owner can mute any channel member (including Admin). Call muteMember to mute a certain member in the chatroom.

// chatRoom  ID of the chatroom where the member to be muted is
// member  ID of the member to be muted
// reason  Reason for muting; this field will be passed-through to the service server via background
// completion  Callback upon muting; services may process it differently according to the corresponding muting result
HMR.getService(ChatRoomService.class).muteMember(ChatRoom chatRoom, User member, null, new HMR.Completion() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onFailed(Error err) {

    }
});

Get a Mute List

You can get a list of muted chatroom users by calling fetchMutedUsers.

// chatRoom  ID of the chatroom to be acquired, to which the list belongs
// completion  Callback upon acquisition; services may process it differently according to the corresponding acquisition result; if acquisition is successful, array of the corresponding muted member will be returned as well
HMR.getService(ChatRoomService.class).fetchMutedUsers(mChatRoom, new HMR.CompletionArg<Set<User>>() {
    @Override
    public void onSuccess(Set<User> members) {

    }

    @Override
    public void onFailed(Error error) {

    }
});

Determine a user’s mute status

You can determine whether a specific chatroom user is muted or not by calling isMuted.

// chatRoom  Chatroom ID of list to be acquired
// member  ID of the member to be judged
// completion  Callback upon judgment; services may process  it differently according to the corresponding judgment result; a true result indicates the user is muted, and a false result indicates the user is not muted
HMR.getService(ChatRoomService.class).isMuted(ChatRoom chatRoom, HMR.getMe(),new HMR.CompletionArg<Boolean>() {
    @Override
    public void onSuccess(Boolean isMuted) {

    }

    @Override
    public void onFailed(Error error) {

    }
});

Unmute Chatroom Members

The unmuteMember is called to unmute a specific chatroom member in accordance with corresponding requirements.

// chatRoom  ID of the chatroom where the member to be unmuted
// member  ID of the member to be unmuted
// reason  Reason for unmuting; this field will be passed-through to the business server via background
// completion  Callback upon unmuting; services may process  it differently according to the corresponding unmuting result
HMR.getService(ChatRoomService.class).unmuteMember(ChatRoom chatRoom, User member, null,new HMR.Completion() {
    @Override
    public void onSuccess() {

    }

    @Override
    public void onFailed(Error err) {

    }
});

3. API Reference

4. Notices

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top
<