呼叫端 | 被呼叫端 |
| |
members.json
文件中,我们已经预配置了一些测试用的用户信息。您可以选择两个账号,分别在两台手机上使用我们配置的 userId 登录,然后在会议中点击底部栏的邀请 > 添加成员以唤起通讯录,在通讯录中选择另一个用户并点击确认进行呼叫。这样,另一个用户就会收到您的呼叫。// 将 SelectParticipantActivity.class 替换为自定义通讯录的activityConferenceSession.sharedInstance().setContactsViewProvider(SelectParticipantActivity.class);
// 将 SelectParticipantActivity::class.java 替换为自定义通讯录的 activityConferenceSession.sharedInstance().setContactsViewProvider(SelectParticipantActivity::class.java)
SelectParticipantActivity
为自定义通讯录代码示例,您可在 Demo 工程下(目录:app/src/main/java/com/tencent/liteav/demo/SelectParticipants) 查看。Intent intent = new Intent();// participants 为选择完毕的用户列表,必须为 ArrayList<User> 类型。ConferenceParticipants participants = new ConferenceParticipants();// 添加您的成员...intent.putExtra(SELECTED_PARTICIPANTS, participants);setResult(3, intent);finish();
val intent = Intent()// participants 为选择完毕的用户列表,必须为 ArrayList<User> 类型。intent.putExtra(SELECTED_PARTICIPANTS, participants)setResult(3, intent)finish()
members.json
文件中,我们已经预配置了一些测试用的用户信息。您可以选择两个账号,分别在两台手机上使用我们配置的 userId 登录,然后在会议中点击底部栏的邀请 > 添加成员以唤起通讯录,在通讯录中选择另一个用户并点击确认进行呼叫。这样,另一个用户就会收到您的呼叫。ContactViewProtocol
协议。// 示例代码class SelectMemberViewController: UIViewController, ContactViewProtocol {weak var delegate: ContactViewSelectDelegate?var selectedList: [User]func didSelectFinished() {// 在完成选择的方法中通过delegate把选择的成员回调给RoomKitdelegate?.onMemberSelected(self, invitees: selectedMembers)}}
ConferenceParticipants
对象置于您通讯录页面的构造函数参数中,数据来源在第二步的代码中提到。ConferenceParticipants
类中有两个成员:ConferenceSession.sharedInstance.setContactsViewProvider { participants inreturn SelectMemberViewController(participants: participants)}
SelectMembersViewModel
的loadMembers
方法中您可以加载自己的成员列表数据(也可以直接获取 Chat 关系链数据)。// 文件位置:Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/view/component/component└──InvitationReceivedView.java
// 文件位置:iOS/TUIRoomKit/Source/View/ConferenceOptions/ConferenceInvitationConferenceInvitation└── ConferenceInvitationViewController.swift // 被呼叫页面视图
// 文件位置:Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/view/page/widget/UserControlPanel/UserControlPanel└── CallUserView.java // 成员列表呼叫按钮
// 文件位置:iOS/TUIRoomKit/Source/Page/Widget/UserControlPanelUserControlPanel // 成员列表相关的视图目录└── UserListCell.swift // 成员列表中单个成员视图,包含用户呼叫状态视图
// 文件位置:TUIRoomKit/blob/main/Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/model/controller/InvitationController.javapublic void inviteUsers(List<UserState.UserInfo> userInfoList, TUIConferenceInvitationManager.InviteUsersCallback callback) {Log.d(TAG, "inviteUsers");if (userInfoList.isEmpty()) {return;}RoomToast.toastShortMessageCenter(TUILogin.getAppContext().getString(R.string.tuiroomkit_invitation_has_been_sent));mConferenceInvitationManager.inviteUsers(mRoomState.roomId.get(), getUserIdListFromUserList(userInfoList), INVITE_TIME_OUT_SECONDS, "", new TUIConferenceInvitationManager.InviteUsersCallback() {@Overridepublic void onSuccess(Map<String, TUIConferenceInvitationManager.InvitationCode> invitationResultMap) {Log.d(TAG, "inviteUsers success");if (callback != null) {callback.onSuccess(invitationResultMap);}}@Overridepublic void onError(TUICommonDefine.Error error, String message) {Log.d(TAG, "inviteUsers error=" + error + " message=" + message);if (callback != null) {callback.onError(error, message);}}});}
// 文件位置:TUIRoomKit/iOS/TUIRoomKit/Source/Service/ConferenceInvitationService.swiftfunc inviteUsers(roomId: String, userIdList: [String]) -> AnyPublisher<InviteUsersResult, RoomError> {return Future<InviteUsersResult, RoomError> { [weak self] promise inguard let self = self else { return }self.invitationManager?.inviteUsers(roomId, userIdList: userIdList, timeout: timeout, extensionInfo: "") {dic inpromise(.success((dic)))} onError: { error, message inpromise(.failure(RoomError(error: error, message: message)))}}.eraseToAnyPublisher()}
// 文件位置:TUIRoomKit/blob/main/Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/model/controller/InvitationController.javapublic void accept(String roomId, TUIRoomDefine.ActionCallback callback) {Log.d(TAG, "accept");mConferenceInvitationManager.accept(roomId, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {Log.d(TAG, "accept success");if (callback != null) {callback.onSuccess();}}@Overridepublic void onError(TUICommonDefine.Error error, String message) {Log.d(TAG, "accept error=" + error + " message=" + message);if (callback != null) {callback.onError(error, message);}}});}
// 文件位置:TUIRoomKit/iOS/TUIRoomKit/Source/Service/ConferenceInvitationService.swiftfunc accept(roomId: String) -> AnyPublisher<String, RoomError> {return Future<String, RoomError> { [weak self] promise inguard let self = self else { return }self.invitationManager?.accept(roomId) {promise(.success(roomId))} onError: { error, message inpromise(.failure(RoomError(error: error, message: message)))}}.eraseToAnyPublisher()}
// 文件位置:TUIRoomKit/Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/model/controller/InvitationController.javapublic void reject(String roomId, TUIConferenceInvitationManager.RejectedReason reason, TUIRoomDefine.ActionCallback callback) {Log.d(TAG, "reject roomId= " + roomId + " reason=" + reason);mConferenceInvitationManager.reject(roomId, reason, new TUIRoomDefine.ActionCallback() {@Overridepublic void onSuccess() {Log.d(TAG, "reject success");if (callback != null) {callback.onSuccess();}}@Overridepublic void onError(TUICommonDefine.Error error, String message) {Log.d(TAG, "reject error=" + error + " message=" + message);if (callback != null) {callback.onError(error, message);}}});}
// 文件位置:TUIRoomKit/iOS/TUIRoomKit/Source/Service/ConferenceInvitationService.swiftfunc reject(roomId: String, reason: TUIInvitationRejectedReason) -> AnyPublisher<String, RoomError> {return Future<String, RoomError> { [weak self] promise inguard let self = self else { return }self.invitationManager?.reject(roomId, reason: reason) {promise(.success(roomId))} onError: { error, message inpromise(.failure(RoomError(error: error, message: message)))}}.eraseToAnyPublisher()}
// 文件位置:TUIRoomKit/Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/model/controller/InvitationController.javaprivate void getInvitationList() {Log.d(TAG, "getInvitationList");mConferenceInvitationManager.getInvitationList(mRoomState.roomId.get(), getAttendeeListCursor, SINGLE_FETCH_COUNT, new TUIConferenceInvitationManager.GetInvitationListCallback() {@Overridepublic void onSuccess(TUIConferenceInvitationManager.InvitationListResult invitationListResult) {Log.d(TAG, "getInvitationList");for (TUIConferenceInvitationManager.Invitation invitation : invitationListResult.invitationList) {InvitationState.Invitation invitationState = new InvitationState.Invitation();invitationState.invitee = new UserState.UserInfo(invitation.invitee);invitationState.inviter = new UserState.UserInfo(invitation.inviter);invitationState.invitationStatus = invitation.status;mInvitationState.invitationList.add(invitationState);}getInvitationListCursor = invitationListResult.cursor;if (!"".equals(getInvitationListCursor)) {getInvitationList();}}@Overridepublic void onError(TUICommonDefine.Error error, String message) {Log.d(TAG, "getInvitationList onError error=" + error + " message=" + message);}});}
// 文件位置:TUIRoomKit/iOS/TUIRoomKit/Source/Service/ConferenceInvitationService.swiftfunc getInvitationList(roomId: String, cursor: String, count: Int = 20) -> AnyPublisher<InvitationfetchResult, RoomError> {return Future<InvitationfetchResult, RoomError> { [weak self] promise inguard let self = self else { return }self.invitationManager?.getInvitationList(roomId, cursor: cursor, count: count) {invitations, cursor inpromise(.success((invitations, cursor)))} onError: { error, message inpromise(.failure(RoomError(error: error, message: message)))}}.eraseToAnyPublisher()}
// 文件位置:TUIRoomKit/Android/tuiroomkit/src/main/java/com/tencent/cloud/tuikit/roomkit/model/ConferenceServiceInitializer.javaprivate void initConferenceInvitationObserver() {TUIConferenceInvitationManager invitationManager = (TUIConferenceInvitationManager) TUIRoomEngine.sharedInstance().getExtension(TUICommonDefine.ExtensionType.CONFERENCE_INVITATION_MANAGER);invitationManager.addObserver(new TUIConferenceInvitationManager.Observer() {@Overridepublic void onReceiveInvitation(TUIRoomDefine.RoomInfo roomInfo, TUIConferenceInvitationManager.Invitation invitation, String extensionInfo) {if (ConferenceController.sharedInstance().getViewState().isInvitationPending.get()) {ConferenceController.sharedInstance().getInvitationController().reject(roomInfo.roomId, REJECT_TO_ENTER, null);return;}if (ConferenceController.sharedInstance().getRoomController().isInRoom()) {ConferenceController.sharedInstance().getInvitationController().reject(roomInfo.roomId, IN_OTHER_CONFERENCE, null);return;}Bundle bundle = new Bundle();bundle.putString("roomId", roomInfo.roomId);bundle.putString("conferenceName", roomInfo.name);bundle.putString("ownerName", roomInfo.ownerName);bundle.putString("inviterName", invitation.inviter.userName);bundle.putString("inviterAvatarUrl", roomInfo.ownerAvatarUrl);bundle.putInt("memberCount", roomInfo.memberCount);TUICore.startActivity("InvitationReceivedActivity", bundle);}});}
// 文件位置:TUIRoomKit/iOS/TUIRoomKit/Source/Service/InvitationObserverService.swiftfunc onReceiveInvitation(roomInfo: TUIRoomInfo, invitation: TUIInvitation, extensionInfo: String) {let store = Container.shared.conferenceStore()store.dispatch(action: ConferenceInvitationActions.onReceiveInvitation(payload: (roomInfo, invitation)))}
本页内容是否解决了您的问题?