UserModule

public final class UserModule

User feature module.

Provides user related Feature, including Subscription event management, Online Status Query, User profile management, Friend management and Friend application etc.. This class Singleton, Via com.nexconn.chat.NCEngine.userModule Get unique Instance. pair external Not expose any internal dependency.

Usage Example:

// Subscribe User online status Event
val params = SubscribeEventParams(SubscribeType.ONLINE_STATUS, listOf("userId1", "userId2")).apply {
expiry = 7 * 24 * 60 * 60 // 7days validity period
}
NCEngine.user.subscribeEvent(params) { failedUserIds, error ->
if (error == null) {
// Subscribed successfully
} else {
// Subscription failed, failedUserIds Contains failed usersIDList
}
}

// Update user profile
val profileParams = UpdateUserProfileParams().apply {
name = "New Nickname"
gender = Gender.MALE
}
NCEngine.user.updateMyUserProfile(profileParams) { errorKeys, error ->
if (error == null) {
// Updated successfully
} else {
// Update failed, errorKeys Contains failed fields Key List
}
}

// Add friend
val addParams = AddFriendParams("userId").apply {
extra = "Hello, please add me friend"
}
NCEngine.user.addFriend(addParams) { resultCode, error ->
// ...
}

// Query friend List
NCEngine.user.getFriends(FriendDirection.BOTH) { friends, error ->
if (error == null && friends != null) {
friends.forEach { friend ->
println("${friend.userId}: ${friend.name}")
}
}
}

Functions

Link copied to clipboard
public final Unit acceptFriendApplication(String userId, ErrorHandler handler)

accept Friend application.

Link copied to clipboard
public final Unit addFriend(AddFriendParams params, OperationHandler<Integer> handler)

Add friend.

Link copied to clipboard
public final Unit addToBlocklist(String userId, ErrorHandler handler)

Add user to block list.

Link copied to clipboard
public final Unit checkBlocked(String userId, OperationHandler<Boolean> handler)

Check if specified user is in block list.

Link copied to clipboard
public final Unit checkFriends(CheckFriendsParams params, OperationHandler<List<FriendRelation>> handler)

Check friend relationship.

Link copied to clipboard

Create Friend application pagination query object.

Link copied to clipboard

Create Subscription event pagination query object.

Link copied to clipboard
public final Unit deleteFriends(DeleteFriendsParams params, ErrorHandler handler)

Batch Delete friend.

Link copied to clipboard
public final Unit getBlocklist(OperationHandler<List<String>> handler)

Get current user's block list.

Link copied to clipboard

Get Friend add permission.

Link copied to clipboard
public final Unit getFriends(FriendDirection direction, OperationHandler<List<FriendDetail>> handler)

Get friend List.

Link copied to clipboard
public final Unit getFriendsInfo(List<String> userIds, OperationHandler<List<FriendDetail>> handler)

Batch Get Friend info.

Link copied to clipboard

Get Current user profile.

Link copied to clipboard

Get Current user profile Visibility.

Link copied to clipboard

Query current subscription event status.

Link copied to clipboard
public final Unit getSubscribeUsersOnlineStatus(List<String> userIds, OperationHandler<List<UserOnlineStatus>> handler)

Batch Query Already Subscribe user Online Status.

Link copied to clipboard
public final Unit getUserProfiles(List<String> userIdList, OperationHandler<List<UserProfileInfo>> handler)

Batch Get user profile.

Link copied to clipboard
public final Unit refuseFriendApplication(String userId, ErrorHandler handler)

reject Friend application.

Link copied to clipboard
public final Unit removeFromBlocklist(String userId, ErrorHandler handler)

Remove user from block list.

Link copied to clipboard
public final Unit searchFriendsInfo(String name, OperationHandler<List<FriendDetail>> handler)

by Name Search Friend info.

Link copied to clipboard
public final Unit setFriendAddPermission(FriendPermission permission, ErrorHandler handler)

Set Friend add permission.

Link copied to clipboard
public final Unit setFriendInfo(SetFriendInfoParams params, ErrorDetailHandler<List<String>> handler)

Set friend info.

Link copied to clipboard
public final Unit subscribeEvent(SubscribeEventParams params, ErrorDetailHandler<List<String>> handler)

Subscribe to user status events.

Link copied to clipboard
public final Unit unSubscribeEvent(SubscribeEventParams params, ErrorDetailHandler<List<String>> handler)

Unsubscribe from user status events.

Link copied to clipboard
public final Unit updateMyUserProfile(UpdateUserProfileParams params, ErrorDetailHandler<List<String>> handler)

Update Current user profile.

Link copied to clipboard

Update Current user profile Visibility.