diff --git a/AUIKitCore.podspec b/AUIKitCore.podspec index 3c4b6649..8cc053c4 100644 --- a/AUIKitCore.podspec +++ b/AUIKitCore.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'AUIKitCore' - s.version = '0.5.1' + s.version = '0.5.2' s.summary = 'A short description of AUIKit.' # This description is used to generate tags and improve search results. diff --git a/Android/README.md b/Android/README.md index d3cb3251..05d0826e 100644 --- a/Android/README.md +++ b/Android/README.md @@ -6,25 +6,25 @@ AUIKit is a set of scaffolding for scenario-based applications. It provides UI c ## Features - [AUIKit](auikit) - - [Service](auikit/src/main/java/io/agora/auikit/service)**([Document](doc/AUIKit-Service.md))** - - [AUIRoomManager](auikit/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) - - [AUIUserService](auikit/src/main/java/io/agora/auikit/service/IAUIUserService.java) - - [AUIMicSeatService](auikit/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) - - [AUIMusicPlayerService](auikit/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) - - [AUIChorusService](auikit/src/main/java/io/agora/auikit/service/IAUIChorusService.java) - - [AUIJukeboxService](auikit/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) - - [UI](auikit/src/main/java/io/agora/auikit/ui)**([Document](doc/AUIKit-UI.md))** - - [Feature UI Widgets](auikit/src/main/java/io/agora/auikit/ui) - - [AUIMicSeatsView](auikit/src/main/java/io/agora/auikit/ui/micseats/IMicSeatsView.java) - - [AUIJukeboxView](auikit/src/main/java/io/agora/auikit/ui/jukebox/IAUIJukeboxView.java) - - [AUIMusicPlayerView](auikit/src/main/java/io/agora/auikit/ui/musicplayer/IMusicPlayerView.java) - - [AUIMemberView](auikit/src/main/java/io/agora/auikit/ui/member/IMemberListView.java) - - [Basic UI Widgets](auikit/src/main/java/io/agora/auikit/ui/basic) - - [AUIButton](auikit/src/main/java/io/agora/auikit/ui/basic/AUIButton.java) - - [AUIBottomDialog](auikit/src/main/java/io/agora/auikit/ui/basic/AUIBottomDialog.java) - - [AUIAlertDialog](auikit/src/main/java/io/agora/auikit/ui/basic/AUIAlertDialog.java) - - [AUITabLayout](auikit/src/main/java/io/agora/auikit/ui/basic/AUITabLayout.java) - - [AUIEditText](auikit/src/main/java/io/agora/auikit/ui/basic/AUIEditText.java) + - [Service](auikit-service/src/main/java/io/agora/auikit/service)**([Document](doc/AUIKit-Service.md))** + - [AUIRoomManager](auikit-service/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) + - [AUIUserService](auikit-service/src/main/java/io/agora/auikit/service/IAUIUserService.java) + - [AUIMicSeatService](auikit-service/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) + - [AUIMusicPlayerService](auikit-service/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) + - [AUIChorusService](auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java) + - [AUIJukeboxService](auikit-service/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) + - [UI](auikit-ui/src/main/java/io/agora/auikit/ui)**([Document](doc/AUIKit-UI.md))** + - [Feature UI Widgets](auikit-ui/src/main/java/io/agora/auikit/ui) + - [AUIMicSeatsView](auikit-ui/src/main/java/io/agora/auikit/ui/micseats/IMicSeatsView.java) + - [AUIJukeboxView](auikit-ui/src/main/java/io/agora/auikit/ui/jukebox/IAUIJukeboxView.java) + - [AUIMusicPlayerView](auikit-ui/src/main/java/io/agora/auikit/ui/musicplayer/IMusicPlayerView.java) + - [AUIMemberView](auikit-ui/src/main/java/io/agora/auikit/ui/member/IMemberListView.java) + - [Basic UI Widgets](auikit-ui/src/main/java/io/agora/auikit/ui/basic) + - [AUIButton](auikit-ui/src/main/java/io/agora/auikit/ui/basic/AUIButton.java) + - [AUIBottomDialog](auikit-ui/src/main/java/io/agora/auikit/ui/basic/AUIBottomDialog.java) + - [AUIAlertDialog](auikit-ui/src/main/java/io/agora/auikit/ui/basic/AUIAlertDialog.java) + - [AUITabLayout](auikit-ui/src/main/java/io/agora/auikit/ui/basic/AUITabLayout.java) + - [AUIEditText](auikit-ui/src/main/java/io/agora/auikit/ui/basic/AUIEditText.java) - ... ## Quick Start diff --git a/Android/README.zh.md b/Android/README.zh.md index 9d327740..56e226d4 100644 --- a/Android/README.zh.md +++ b/Android/README.zh.md @@ -6,13 +6,13 @@ AUIKit是一套场景化应用的脚手架,提供Ui组件以及Service组件 ## 特性 - [AUIKit](auikit) - - [Service](auikit-ui/src/main/java/io/agora/auikit/service)**([使用指南](doc/AUIKit-Service.md))** - - [AUIRoomManager](auikit-ui/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) - - [AUIUserService](auikit-ui/src/main/java/io/agora/auikit/service/IAUIUserService.java) - - [AUIMicSeatService](auikit-ui/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) - - [AUIMusicPlayerService](auikit-ui/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) - - [AUIChorusService](auikit-ui/src/main/java/io/agora/auikit/service/IAUIChorusService.java) - - [AUIJukeboxService](auikit-ui/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) + - [Service](auikit-service/src/main/java/io/agora/auikit/service)**([使用指南](doc/AUIKit-Service.md))** + - [AUIRoomManager](auikit-service/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) + - [AUIUserService](auikit-service/src/main/java/io/agora/auikit/service/IAUIUserService.java) + - [AUIMicSeatService](auikit-service/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) + - [AUIMusicPlayerService](auikit-service/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) + - [AUIChorusService](auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java) + - [AUIJukeboxService](auikit-service/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) - [UI](auikit-ui/src/main/java/io/agora/auikit/ui)**([使用指南](doc/AUIKit-UI.md))** - [Feature UI Widgets](auikit-ui/src/main/java/io/agora/auikit/ui) - [AUIMicSeatsView](auikit-ui/src/main/java/io/agora/auikit/ui/micseats/IMicSeatsView.java) diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/model/AUICommonConfig.java b/Android/auikit-service/src/main/java/io/agora/auikit/model/AUICommonConfig.java index aa55020c..d1f5ad17 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/model/AUICommonConfig.java +++ b/Android/auikit-service/src/main/java/io/agora/auikit/model/AUICommonConfig.java @@ -6,7 +6,7 @@ public class AUICommonConfig { public @NonNull Context context; - public @NonNull String appId = ""; + public @NonNull String host = ""; public @NonNull String userId = ""; public @NonNull String userName = ""; public @NonNull String userAvatar = ""; //用户头像 diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/model/AUIRoomContext.java b/Android/auikit-service/src/main/java/io/agora/auikit/model/AUIRoomContext.java index 7c25fa0f..c4d3d304 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/model/AUIRoomContext.java +++ b/Android/auikit-service/src/main/java/io/agora/auikit/model/AUIRoomContext.java @@ -8,17 +8,22 @@ import java.util.Map; public class AUIRoomContext { - private static AUIRoomContext instance = null; + private static volatile AUIRoomContext instance = null; private AUIRoomContext() { // 私有构造函数 } - public static synchronized AUIRoomContext shared() { + public static AUIRoomContext shared() { if (instance == null) { - instance = new AUIRoomContext(); + synchronized (AUIRoomContext.class){ + if(instance == null){ + instance = new AUIRoomContext(); + } + } } return instance; } + public String appId = ""; public Map roomConfigMap = new HashMap<>(); public @NonNull AUIUserThumbnailInfo currentUserInfo = new AUIUserThumbnailInfo(); diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java b/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java index d749b6a7..2e46f023 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java @@ -7,7 +7,7 @@ import io.agora.auikit.service.callback.AUIChoristerListCallback; import io.agora.auikit.service.callback.AUISwitchSingerRoleCallback; -public interface IAUIChorusService extends IAUICommonService { +public interface IAUIChorusService extends IAUICommonService { // 获取合唱者列表 @@ -22,7 +22,7 @@ public interface IAUIChorusService extends IAUICommonService void onChoristerDidEnter(AUIChoristerModel chorister); diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUICommonService.java b/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUICommonService.java index 3385264c..f3b27783 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUICommonService.java +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUICommonService.java @@ -5,21 +5,21 @@ import io.agora.auikit.model.AUIRoomContext; -public interface IAUICommonService { +public interface IAUICommonService { /** * 绑定响应事件回调,可绑定多个 * - * @param delegate 响应事件回调 + * @param observer 响应事件回调 */ - void bindRespDelegate(@Nullable Delegate delegate); + void registerRespObserver(@Nullable Observer observer); /** * 解绑响应事件回调 * - * @param delegate 响应事件回调 + * @param observer 响应事件回调 */ - void unbindRespDelegate(@Nullable Delegate delegate); + void unRegisterRespObserver(@Nullable Observer observer); /** 获取当前房间上下文 * diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIGiftsService.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIGiftsService.kt index 113871d0..2f9a05f1 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIGiftsService.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/IAUIGiftsService.kt @@ -4,7 +4,7 @@ import io.agora.auikit.model.AUIGiftEntity import io.agora.auikit.service.callback.AUICallback import io.agora.auikit.service.callback.AUIGiftListCallback -interface IAUIGiftsService : IAUICommonService { +interface IAUIGiftsService : IAUICommonService { /** * - roomId: 房间id @@ -19,7 +19,7 @@ interface IAUIGiftsService : IAUICommonService{ +interface IAUIIMManagerService: IAUICommonService{ /** @@ -30,7 +30,7 @@ interface IAUIIMManagerService: IAUICommonService { +public interface IAUIInvitationService extends IAUICommonService { /** * 向用户发送邀请 * @param userId 邀请用户id @@ -66,7 +66,7 @@ public interface IAUIInvitationService extends IAUICommonService { +public interface IAUIJukeboxService extends IAUICommonService { // 0 -> "项目热歌榜单" // 1 -> "声网热歌榜" @@ -88,7 +88,7 @@ public interface IAUIJukeboxService extends IAUICommonService { +public interface IAUIMicSeatService extends IAUICommonService { /** * 主动上麦(听众端和房主均可调用) @@ -96,7 +96,7 @@ public interface IAUIMicSeatService extends IAUICommonService { +public interface IAUIMusicPlayerService extends IAUICommonService { /** * 异步加载歌曲,同时只能为一首歌loadSong,loadSong结果会通过回调通知业务层 * @param songCode 歌曲唯一编码 @@ -109,7 +109,7 @@ public interface IAUIMusicPlayerService extends IAUICommonService { +public interface IAUIRoomManager extends IAUICommonService { /** * 创建房间(房主调用),若房间不存在,系统将自动创建一个新房间 * @@ -70,7 +70,7 @@ public interface IAUIRoomManager extends IAUICommonService { +public interface IAUIUserService extends IAUICommonService { /** * 获取指定 userId 的用户信息,如果为 null,则获取房间内所有人的信息 @@ -45,7 +45,7 @@ public interface IAUIUserService extends IAUICommonService() + private val chatEvnetHandlers = mutableListOf() private var chatRoomId:String? = "" private var channelId:String? = "" private var appKey:String? ="" @@ -57,12 +57,12 @@ class AUIChatManager( this.roomContext = roomContext } - fun subscribeChatMsg(delegate: AUIChatSubscribeDelegate) { - chatSubscribeDelegates.add(delegate) + fun subscribeChatMsg(delegate: AUIChatEventHandler) { + chatEvnetHandlers.add(delegate) } - fun unsubscribeChatMsg(delegate: AUIChatSubscribeDelegate?) { - chatSubscribeDelegates.remove(delegate) + fun unsubscribeChatMsg(delegate: AUIChatEventHandler?) { + chatEvnetHandlers.remove(delegate) } fun initManager() { @@ -218,7 +218,7 @@ class AUIChatManager( if (it.type == ChatMessage.Type.TXT) { parseMsgChatEntity(it) try { - for (listener in chatSubscribeDelegates) { + for (listener in chatEvnetHandlers) { listener.onReceiveTextMsg(channelId,parseChatMessage(it)) } } catch (e: Exception) { @@ -240,7 +240,7 @@ class AUIChatManager( AUICustomMsgType.AUIChatRoomJoinedMember -> { parseMsgChatEntity(it) try { - for (listener in chatSubscribeDelegates) { + for (listener in chatEvnetHandlers) { listener.onReceiveMemberJoinedMsg(channelId,parseChatMessage(it)) } } catch (e: Exception) { @@ -465,7 +465,7 @@ class AUIChatManager( participant: String? ) { try { - for (listener in chatSubscribeDelegates) { + for (listener in chatEvnetHandlers) { listener.onUserBeKicked(chatRoomId,getKickReason(reason)) } } catch (e: Exception) { @@ -475,7 +475,7 @@ class AUIChatManager( override fun onChatRoomDestroyed(chatRoomId: String?, roomName: String?) { try { - for (listener in chatSubscribeDelegates) { + for (listener in chatEvnetHandlers) { listener.onRoomDestroyed(chatRoomId) } } catch (e: Exception) { diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImplResp.kt similarity index 87% rename from Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt rename to Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImplResp.kt index 1fd5525d..eb648c46 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImplResp.kt @@ -20,16 +20,16 @@ import io.agora.auikit.service.ktv.KTVApi import io.agora.auikit.service.ktv.KTVSingRole import io.agora.auikit.service.ktv.SwitchRoleFailReason import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver +import io.agora.auikit.utils.ObservableHelper import retrofit2.Call import retrofit2.Response -class AUIChorusServiceImpl constructor( +class AUIChorusServiceImplResp constructor( private val channelName: String, private val ktvApi: KTVApi, private val rtmManager: AUIRtmManager -) : IAUIChorusService, AUIRtmMsgProxyDelegate { +) : IAUIChorusService, AUIRtmMsgRespObserver { private val TAG: String = "Chorus_LOG" private val kChorusKey = "chorus" @@ -44,13 +44,14 @@ class AUIChorusServiceImpl constructor( private var chorusList = mutableListOf() // 合唱者列表 - private val delegateHelper = DelegateHelper() - override fun bindRespDelegate(delegate: IAUIChorusService.AUIChorusRespDelegate?) { - delegateHelper.bindDelegate(delegate) + private val observableHelper = + ObservableHelper() + override fun registerRespObserver(observer: IAUIChorusService.AUIChorusRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIChorusService.AUIChorusRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIChorusService.AUIChorusRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun getChannelName() = channelName @@ -156,7 +157,7 @@ class AUIChorusServiceImpl constructor( } } if (!hasChorister) { - delegateHelper.notifyDelegate { delegate: IAUIChorusService.AUIChorusRespDelegate -> + observableHelper.notifyEventHandlers { delegate: IAUIChorusService.AUIChorusRespObserver -> delegate.onChoristerDidEnter(newChorister) } } @@ -169,7 +170,7 @@ class AUIChorusServiceImpl constructor( } } if (!hasChorister) { - delegateHelper.notifyDelegate { delegate: IAUIChorusService.AUIChorusRespDelegate -> + observableHelper.notifyEventHandlers { delegate: IAUIChorusService.AUIChorusRespObserver -> delegate.onChoristerDidLeave(oldChorister) } } @@ -177,7 +178,7 @@ class AUIChorusServiceImpl constructor( this.chorusList.clear() this.chorusList.addAll(chorusLists) - delegateHelper.notifyDelegate { delegate: IAUIChorusService.AUIChorusRespDelegate -> + observableHelper.notifyEventHandlers { delegate: IAUIChorusService.AUIChorusRespObserver -> //delegate delegate.onChoristerDidChanged() } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIGiftServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIGiftServiceImplResp.kt similarity index 81% rename from Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIGiftServiceImpl.kt rename to Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIGiftServiceImplResp.kt index 66ee4dd3..6ba9635f 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIGiftServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIGiftServiceImplResp.kt @@ -13,21 +13,22 @@ import io.agora.auikit.service.http.Utils import io.agora.auikit.service.http.gift.GiftInterface import io.agora.auikit.service.im.AUIChatManager import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver +import io.agora.auikit.utils.ObservableHelper import io.agora.auikit.utils.GsonTools import org.json.JSONObject import retrofit2.Call import retrofit2.Response private const val giftKey = "AUIChatRoomGift" -class AUIGiftServiceImpl constructor( +class AUIGiftServiceImplResp constructor( private val channelName: String, private val rtmManager: AUIRtmManager, private val chatManager:AUIChatManager -) : IAUIGiftsService, AUIRtmMsgProxyDelegate { +) : IAUIGiftsService, AUIRtmMsgRespObserver { - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() private var roomContext:AUIRoomContext init { @@ -59,12 +60,12 @@ class AUIGiftServiceImpl constructor( rtmManager.sendGiftMetadata(channelName,gift,callback) } - override fun bindRespDelegate(delegate: IAUIGiftsService.AUIGiftRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: IAUIGiftsService.AUIGiftRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIGiftsService.AUIGiftRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIGiftsService.AUIGiftRespObserver?) { + observableHelper.subscribeEvent(observer) } override fun getRoomContext() = roomContext @@ -76,7 +77,7 @@ class AUIGiftServiceImpl constructor( val gift = JSONObject(value.toString()) GsonTools.toBean(gift["messageInfo"].toString(), AUIGiftEntity::class.java)?.let { it -> chatManager.addGiftList(it) - this.delegateHelper.notifyDelegate { it1 -> + this.observableHelper.notifyEventHandlers { it1 -> it1.onReceiveGiftMsg(it) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIIMManagerServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIIMManagerServiceImpl.kt index dd13ce60..790648fe 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIIMManagerServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIIMManagerServiceImpl.kt @@ -15,12 +15,12 @@ import io.agora.auikit.service.http.room.CreateChatRoomReq import io.agora.auikit.service.http.room.CreateChatRoomRsp import io.agora.auikit.service.http.room.RoomInterface import io.agora.auikit.service.im.AUIChatManager -import io.agora.auikit.service.im.AUIChatSubscribeDelegate +import io.agora.auikit.service.im.AUIChatEventHandler import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver import io.agora.auikit.utils.AUILogger import io.agora.auikit.utils.AgoraEngineCreator -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.utils.ObservableHelper import io.agora.auikit.utils.ThreadManager import io.agora.chat.ChatMessage import org.json.JSONObject @@ -33,10 +33,11 @@ class AUIIMManagerServiceImpl constructor( private val channelName: String, private val rtmManager: AUIRtmManager, private val chatManager: AUIChatManager -) : IAUIIMManagerService, AUIRtmMsgProxyDelegate, AUIChatSubscribeDelegate { +) : IAUIIMManagerService, AUIRtmMsgRespObserver, AUIChatEventHandler { private val roomContext = AUIRoomContext.shared() private val mChatRoomIdMap = mutableMapOf() - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() init { rtmManager.subscribeMsg(channelName, chatRoomIdKey, this) @@ -93,7 +94,7 @@ class AUIIMManagerServiceImpl constructor( .e(message = "IM join chat room failed! -- $error") return } - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.onUserDidJoinRoom( chatRoomId!!, IAUIIMManagerService.AgoraChatTextMessage( message?.msgId, message?.body?.toString(), null @@ -117,7 +118,7 @@ class AUIIMManagerServiceImpl constructor( .e(message = "IM join chat room failed! -- $error") return } - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.onUserDidJoinRoom( chatRoomId, IAUIIMManagerService.AgoraChatTextMessage( message?.msgId, message?.body?.toString(), null @@ -133,12 +134,12 @@ class AUIIMManagerServiceImpl constructor( } - override fun bindRespDelegate(delegate: IAUIIMManagerService.AUIIMManagerRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: IAUIIMManagerService.AUIIMManagerRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIIMManagerService.AUIIMManagerRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIIMManagerService.AUIIMManagerRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun getRoomContext(): AUIRoomContext = roomContext @@ -277,7 +278,7 @@ class AUIIMManagerServiceImpl constructor( super.onReceiveMemberJoinedMsg(roomId, message) message ?: return roomId ?: return - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.onUserDidJoinRoom( roomId, IAUIIMManagerService.AgoraChatTextMessage( message.messageId, @@ -292,7 +293,7 @@ class AUIIMManagerServiceImpl constructor( super.onReceiveTextMsg(roomId, message) message ?: return roomId ?: return - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.messageDidReceive( roomId, IAUIIMManagerService.AgoraChatTextMessage( diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIInvitationServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIInvitationServiceImplResp.kt similarity index 94% rename from Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIInvitationServiceImpl.kt rename to Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIInvitationServiceImplResp.kt index 61ad87a8..30fdc63f 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIInvitationServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIInvitationServiceImplResp.kt @@ -18,8 +18,8 @@ import io.agora.auikit.service.http.invitation.InvitationInterface import io.agora.auikit.service.http.invitation.InvitationPayload import io.agora.auikit.service.http.invitation.RejectInvitationAccept import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver +import io.agora.auikit.utils.ObservableHelper import io.agora.auikit.utils.GsonTools import io.agora.auikit.utils.ThreadManager import retrofit2.Call @@ -28,10 +28,10 @@ import retrofit2.Response private const val RoomApplyKey = "application" private const val RoomInvitationKey = "invitation" -class AUIInvitationServiceImpl( +class AUIInvitationServiceImplResp( private val channelName: String, private val rtmManager: AUIRtmManager -) : IAUIInvitationService, AUIRtmMsgProxyDelegate { +) : IAUIInvitationService, AUIRtmMsgRespObserver { private val roomContext:AUIRoomContext init { @@ -40,14 +40,15 @@ class AUIInvitationServiceImpl( this.roomContext = AUIRoomContext.shared() } - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() - override fun bindRespDelegate(delegate: IAUIInvitationService.AUIInvitationRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: IAUIInvitationService.AUIInvitationRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIInvitationService.AUIInvitationRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIInvitationService.AUIInvitationRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun sendInvitation(userId: String, seatIndex: Int, callback: AUICallback?) { @@ -269,14 +270,14 @@ class AUIInvitationServiceImpl( override fun onMsgDidChanged(channelName: String, key: String, value: Any) { Log.e("apex","AUiServiceImpl key: $key") if (key == RoomApplyKey){ //申请 - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { val list = paresData(value) if (list.size > 0){ it.onApplyListUpdate(paresData(value)) } } }else if (key == RoomInvitationKey){//邀请 - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { val list = paresData(value) if (list.size > 0 && list[list.lastIndex].userId == roomContext.currentUserInfo.userId){ it.onReceiveInvitation(list[list.lastIndex].userId,list[list.lastIndex].micIndex) diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImplResp.kt similarity index 96% rename from Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt rename to Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImplResp.kt index bc4d896e..759d3ea2 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImplResp.kt @@ -9,7 +9,7 @@ import io.agora.auikit.model.AUIChooseMusicModel import io.agora.auikit.model.AUIMusicModel import io.agora.auikit.model.AUIPlayStatus import io.agora.auikit.service.IAUIJukeboxService -import io.agora.auikit.service.IAUIJukeboxService.AUIJukeboxRespDelegate +import io.agora.auikit.service.IAUIJukeboxService.AUIJukeboxRespObserver import io.agora.auikit.service.callback.AUICallback import io.agora.auikit.service.callback.AUIChooseSongListCallback import io.agora.auikit.service.callback.AUIException @@ -25,17 +25,17 @@ import io.agora.auikit.service.http.song.SongRemoveReq import io.agora.auikit.service.http.song.SongStopReq import io.agora.auikit.service.ktv.KTVApi import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver +import io.agora.auikit.utils.ObservableHelper import io.agora.rtc2.Constants import retrofit2.Call import retrofit2.Response -class AUIJukeboxServiceImpl constructor( +class AUIJukeboxServiceImplResp constructor( private val channelName: String, private val rtmManager: AUIRtmManager, private val ktvApi: KTVApi -) : IAUIJukeboxService, AUIRtmMsgProxyDelegate { +) : IAUIJukeboxService, AUIRtmMsgRespObserver { private val TAG: String = "Jukebox_LOG" private val kChooseSongKey = "song" @@ -47,7 +47,8 @@ class AUIJukeboxServiceImpl constructor( private val songInterface by lazy { HttpManager.getService(SongInterface::class.java) } - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() // 选歌列表 private val chooseMusicList = mutableListOf() @@ -56,12 +57,12 @@ class AUIJukeboxServiceImpl constructor( rtmManager.subscribeMsg(channelName, kChooseSongKey, this) } - override fun bindRespDelegate(delegate: AUIJukeboxRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: AUIJukeboxRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: AUIJukeboxRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: AUIJukeboxRespObserver?) { + observableHelper.unSubscribeEvent(observer) } // 获取歌曲列表 @@ -400,7 +401,7 @@ class AUIJukeboxServiceImpl constructor( gson.fromJson(value as String, object : TypeToken>() {}.type) ?: mutableListOf() this.chooseMusicList.clear() this.chooseMusicList.addAll(changedSongs) - delegateHelper.notifyDelegate { delegate: AUIJukeboxRespDelegate -> + observableHelper.notifyEventHandlers { delegate: AUIJukeboxRespObserver -> delegate.onUpdateAllChooseSongs(this.chooseMusicList) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImplResp.kt similarity index 92% rename from Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt rename to Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImplResp.kt index fcad51f4..a312926f 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImplResp.kt @@ -15,19 +15,20 @@ import io.agora.auikit.service.http.seat.SeatInterface import io.agora.auikit.service.http.seat.SeatLeaveReq import io.agora.auikit.service.http.seat.SeatPickReq import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver +import io.agora.auikit.utils.ObservableHelper import io.agora.auikit.utils.GsonTools import retrofit2.Call import retrofit2.Response private const val kSeatAttrKey = "micSeat" -class AUIMicSeatServiceImpl( +class AUIMicSeatServiceImplResp( private val channelName: String, private val rtmManager: AUIRtmManager -) : IAUIMicSeatService, AUIRtmMsgProxyDelegate { +) : IAUIMicSeatService, AUIRtmMsgRespObserver { - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() private var micSeats = mutableMapOf() @@ -35,12 +36,12 @@ class AUIMicSeatServiceImpl( rtmManager.subscribeMsg(channelName, kSeatAttrKey, this) } - override fun bindRespDelegate(delegate: IAUIMicSeatService.AUIMicSeatRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: IAUIMicSeatService.AUIMicSeatRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIMicSeatService.AUIMicSeatRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIMicSeatService.AUIMicSeatRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun enterSeat(seatIndex: Int, callback: AUICallback?) { @@ -239,7 +240,7 @@ class AUIMicSeatServiceImpl( } override fun onClickInvited(index: Int) { - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.onShowInvited(index) } } @@ -273,33 +274,33 @@ class AUIMicSeatServiceImpl( if (oldSeatUserId.isEmpty() && newSeatUserId.isNotEmpty()) { Log.d("mic_seat_update", "onAnchorEnterSeat: $it") val newUser = newSeatInfo.user ?: return - delegateHelper.notifyDelegate { delegate -> + observableHelper.notifyEventHandlers { delegate -> delegate.onAnchorEnterSeat(index, newUser) } } if (oldSeatUserId.isNotEmpty() && newSeatUserId.isEmpty()) { Log.d("mic_seat_update", "onAnchorLeaveSeat: $it") val originUser = oldSeatInfo?.user ?: return - delegateHelper.notifyDelegate { delegate -> + observableHelper.notifyEventHandlers { delegate -> delegate.onAnchorLeaveSeat(index, originUser) } } if ((oldSeatInfo?.seatStatus ?: AUIMicSeatStatus.idle) != newSeatInfo.seatStatus && (oldSeatInfo?.seatStatus == AUIMicSeatStatus.locked || newSeatInfo.seatStatus == AUIMicSeatStatus.locked)) { Log.d("mic_seat_update", "onSeatClose: $it") - delegateHelper.notifyDelegate { delegate -> + observableHelper.notifyEventHandlers { delegate -> delegate.onSeatClose(index, (newSeatInfo.seatStatus == AUIMicSeatStatus.locked)) } } if ((oldSeatInfo?.muteAudio ?: 0) != newSeatInfo.muteAudio) { Log.d("mic_seat_update", "onSeatAudioMute: $it") - delegateHelper.notifyDelegate { delegate -> + observableHelper.notifyEventHandlers { delegate -> delegate.onSeatAudioMute(index, (newSeatInfo.muteAudio != 0)) } } if ((oldSeatInfo?.muteVideo ?: 0) != newSeatInfo.muteVideo) { Log.d("mic_seat_update", "onSeatVideoMute: $it") - delegateHelper.notifyDelegate { delegate -> + observableHelper.notifyEventHandlers { delegate -> delegate.onSeatVideoMute(index, (newSeatInfo.muteVideo != 0)) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt index b7b5a854..1adbe3a7 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt @@ -13,7 +13,7 @@ import io.agora.auikit.service.ktv.KTVLoadMusicMode import io.agora.auikit.service.ktv.KTVLoadSongFailReason import io.agora.auikit.service.ktv.KTVSingRole import io.agora.auikit.service.ktv.MusicLoadStatus -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.utils.ObservableHelper import io.agora.mediaplayer.Constants import io.agora.mediaplayer.Constants.MediaPlayerState import io.agora.rtc2.RtcEngine @@ -23,7 +23,8 @@ class AUIMusicPlayerServiceImpl constructor( private val channelName: String, private val ktvApi: KTVApi ): IAUIMusicPlayerService, IKTVApiEventHandler(), ILrcView { - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() private val rtcEffectProperties :MutableMap by lazy{ mutableMapOf() @@ -44,12 +45,12 @@ class AUIMusicPlayerServiceImpl constructor( } // ----------------- IAUiMusicPlayerService ----------------- - override fun bindRespDelegate(delegate: IAUIMusicPlayerService.AUIPlayerRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: IAUIMusicPlayerService.AUIPlayerRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIMusicPlayerService.AUIPlayerRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIMusicPlayerService.AUIPlayerRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun getChannelName() = channelName @@ -180,7 +181,7 @@ class AUIMusicPlayerServiceImpl constructor( override fun onMusicPlayerStateChanged( state: MediaPlayerState, error: Constants.MediaPlayerError, isLocal: Boolean ) { - delegateHelper.notifyDelegate { delegate: IAUIMusicPlayerService.AUIPlayerRespDelegate -> + observableHelper.notifyEventHandlers { delegate: IAUIMusicPlayerService.AUIPlayerRespObserver -> delegate.onPlayerStateChanged(MediaPlayerState.getValue(state), isLocal) } } @@ -190,13 +191,13 @@ class AUIMusicPlayerServiceImpl constructor( // ----------------- ILrcView ----------------- override fun onUpdatePitch(pitch: Float?) { - delegateHelper.notifyDelegate { delegate: IAUIMusicPlayerService.AUIPlayerRespDelegate -> + observableHelper.notifyEventHandlers { delegate: IAUIMusicPlayerService.AUIPlayerRespObserver -> delegate.onPitchDidChange(pitch) } } override fun onUpdateProgress(progress: Long?) { - delegateHelper.notifyDelegate { delegate: IAUIMusicPlayerService.AUIPlayerRespDelegate -> + observableHelper.notifyEventHandlers { delegate: IAUIMusicPlayerService.AUIPlayerRespObserver -> delegate.onPlayerPositionDidChange(progress) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt index dd17e072..23ab5cde 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt @@ -5,7 +5,7 @@ import io.agora.auikit.model.AUICreateRoomInfo import io.agora.auikit.model.AUIRoomContext import io.agora.auikit.model.AUIRoomInfo import io.agora.auikit.service.IAUIRoomManager -import io.agora.auikit.service.IAUIRoomManager.AUIRoomManagerRespDelegate +import io.agora.auikit.service.IAUIRoomManager.AUIRoomManagerRespObserver import io.agora.auikit.service.callback.AUICallback import io.agora.auikit.service.callback.AUICreateRoomCallback import io.agora.auikit.service.callback.AUIException @@ -23,13 +23,13 @@ import io.agora.auikit.service.http.room.RoomUserReq import io.agora.auikit.service.http.user.KickUserReq import io.agora.auikit.service.http.user.KickUserRsp import io.agora.auikit.service.http.user.UserInterface -import io.agora.auikit.service.rtm.AUIRtmErrorProxyDelegate +import io.agora.auikit.service.rtm.AUIRtmErrorRespObserver import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmMsgProxyDelegate +import io.agora.auikit.service.rtm.AUIRtmMsgRespObserver import io.agora.auikit.utils.AUILogger import io.agora.auikit.utils.AgoraEngineCreator -import io.agora.auikit.utils.DelegateHelper import io.agora.auikit.utils.MapperUtils +import io.agora.auikit.utils.ObservableHelper import io.agora.auikit.utils.ThreadManager import io.agora.rtm2.RtmClient import io.agora.rtm2.RtmConstants @@ -38,10 +38,10 @@ import retrofit2.Response import java.util.concurrent.atomic.AtomicBoolean private const val kRoomAttrKey = "room" -class AUIRoomManagerImpl( +class AUIRoomManagerImplRespResp( private val commonConfig: AUICommonConfig, private val rtmClient: RtmClient? = null, -) : IAUIRoomManager, AUIRtmMsgProxyDelegate, AUIRtmErrorProxyDelegate { +) : IAUIRoomManager, AUIRtmMsgRespObserver, AUIRtmErrorRespObserver { private val subChannelMsg = AtomicBoolean(false) private val subChannelStream = AtomicBoolean(false) @@ -49,7 +49,7 @@ class AUIRoomManagerImpl( val rtmManager by lazy { val rtm = rtmClient ?: AgoraEngineCreator.createRtmClient( commonConfig.context, - commonConfig.appId, + AUIRoomContext.shared().appId, commonConfig.userId ) AUIRtmManager(commonConfig.context, rtm) @@ -57,21 +57,20 @@ class AUIRoomManagerImpl( private val TAG = "AUiRoomManagerImpl" - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() private var mChannelName: String? = null init { AUIRoomContext.shared().commonConfig = commonConfig } - override fun bindRespDelegate(delegate: AUIRoomManagerRespDelegate?) { - delegateHelper.bindDelegate(delegate) - rtmManager.proxy.subscribeError("",this) + override fun registerRespObserver(observer: AUIRoomManagerRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: AUIRoomManagerRespDelegate?) { - delegateHelper.unBindDelegate(delegate) - rtmManager.proxy.unsubscribeError("",this) + override fun unRegisterRespObserver(observer: AUIRoomManagerRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun createRoom( @@ -114,6 +113,7 @@ class AUIRoomManagerImpl( rtmManager.unSubscribe(RtmConstants.RtmChannelType.STREAM,roomId) rtmManager.unSubscribe(RtmConstants.RtmChannelType.MESSAGE,roomId) rtmManager.unsubscribeMsg(roomId,"",this) + rtmManager.proxy.unRegisterErrorRespObserver(this) rtmManager.logout() HttpManager.getService(RoomInterface::class.java) .destroyRoom(RoomUserReq(roomId, roomContext.currentUserInfo.userId)) @@ -165,6 +165,7 @@ class AUIRoomManagerImpl( } else { AUILogger.logger().d(TAG, "EnterRoom rtmManager login success") AUILogger.logger().d(TAG, "EnterRoom subscribeMsg RtmChannelType.MESSAGE room roomId=$roomId token=$token") + rtmManager.proxy.registerErrorRespObserver(this) rtmManager.subscribeMsg(roomId, "", this) rtmManager.subscribe(RtmConstants.RtmChannelType.MESSAGE,roomId, token) { subscribeError -> if (subscribeError != null) { @@ -297,15 +298,15 @@ class AUIRoomManagerImpl( override fun onConnectionStateChanged(channelName: String?, state: Int, reason: Int) { if (state == 5 && reason == 3){ - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.onRoomUserBeKicked(channelName,AUIRoomContext.shared().currentUserInfo.userId) } } } - override fun onMsgRecvEmpty(channelName: String) { + override fun onMsgReceiveEmpty(channelName: String) { if (channelName == getChannelName()) { - delegateHelper.notifyDelegate { + observableHelper.notifyEventHandlers { it.onRoomDestroy(channelName) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImplResp.kt similarity index 88% rename from Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt rename to Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImplResp.kt index 881ee7fe..e44cfa58 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImplResp.kt @@ -7,32 +7,33 @@ import io.agora.auikit.service.callback.AUICallback import io.agora.auikit.service.callback.AUIException import io.agora.auikit.service.callback.AUIUserListCallback import io.agora.auikit.service.rtm.AUIRtmManager -import io.agora.auikit.service.rtm.AUIRtmUserProxyDelegate +import io.agora.auikit.service.rtm.AUIRtmUserRespObserver import io.agora.auikit.utils.AUILogger -import io.agora.auikit.utils.DelegateHelper +import io.agora.auikit.utils.ObservableHelper import io.agora.auikit.utils.GsonTools -class AUIUserServiceImpl constructor( +class AUIUserServiceImplResp constructor( private val channelName: String, private val rtmManager: AUIRtmManager -) : IAUIUserService, AUIRtmUserProxyDelegate { +) : IAUIUserService, AUIRtmUserRespObserver { private val TAG = "AUiUserServiceImpl" private var mUserList = mutableListOf() - private val delegateHelper = DelegateHelper() + private val observableHelper = + ObservableHelper() init { rtmManager.subscribeUser(this) } - override fun bindRespDelegate(delegate: IAUIUserService.AUIUserRespDelegate?) { - delegateHelper.bindDelegate(delegate) + override fun registerRespObserver(observer: IAUIUserService.AUIUserRespObserver?) { + observableHelper.subscribeEvent(observer) } - override fun unbindRespDelegate(delegate: IAUIUserService.AUIUserRespDelegate?) { - delegateHelper.unBindDelegate(delegate) + override fun unRegisterRespObserver(observer: IAUIUserService.AUIUserRespObserver?) { + observableHelper.unSubscribeEvent(observer) } override fun getUserInfoList( @@ -81,7 +82,7 @@ class AUIUserServiceImpl constructor( ) ) } else { - this.delegateHelper.notifyDelegate { + this.observableHelper.notifyEventHandlers { it.onUserAudioMute(currentUserId, isMute) } callback?.onResult(null) @@ -138,7 +139,7 @@ class AUIUserServiceImpl constructor( } } mUserList = users - this.delegateHelper.notifyDelegate { + this.observableHelper.notifyEventHandlers { it.onRoomUserSnapshot(channelName, mUserList) } setupUserAttr(channelName) @@ -152,7 +153,7 @@ class AUIUserServiceImpl constructor( GsonTools.toBean(GsonTools.beanToString(userInfo), AUIUserInfo::class.java)?.let { info -> info.userId = userId mUserList.add(info) - this.delegateHelper.notifyDelegate { + this.observableHelper.notifyEventHandlers { it.onRoomUserEnter(channelName, info) } } @@ -165,7 +166,7 @@ class AUIUserServiceImpl constructor( ) { val index = mUserList.indexOfFirst{ it.userId == userId } val info = mUserList.removeAt(index) - this.delegateHelper.notifyDelegate { + this.observableHelper.notifyEventHandlers { it.onRoomUserLeave(channelName, info) } } @@ -187,12 +188,12 @@ class AUIUserServiceImpl constructor( mUserList[index] = info // 单独更新语音被禁用回调 if (oldInfo.muteAudio != info.muteAudio) { - this.delegateHelper.notifyDelegate { + this.observableHelper.notifyEventHandlers { it.onUserAudioMute(info.userId, (info.muteAudio == 1)) } } } - this.delegateHelper.notifyDelegate { + this.observableHelper.notifyEventHandlers { it.onRoomUserUpdate(channelName, info) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmManager.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmManager.kt index 25ecdd1a..a6a816ec 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmManager.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmManager.kt @@ -117,20 +117,20 @@ class AUIRtmManager( isLogin = false } - fun subscribeMsg(channelName: String, itemKey: String, delegate: AUIRtmMsgProxyDelegate) { - proxy.subscribeMsg(channelName, itemKey, delegate) + fun subscribeMsg(channelName: String, itemKey: String, handler: AUIRtmMsgRespObserver) { + proxy.registerMsgRespObserver(channelName, itemKey, handler) } - fun unsubscribeMsg(channelName: String, itemKey: String, delegate: AUIRtmMsgProxyDelegate) { - proxy.unsubscribeMsg(channelName, itemKey, delegate) + fun unsubscribeMsg(channelName: String, itemKey: String, handler: AUIRtmMsgRespObserver) { + proxy.unRegisterMsgRespObserver(channelName, itemKey, handler) } - fun subscribeUser(delegate: AUIRtmUserProxyDelegate) { - proxy.subscribeUser(delegate) + fun subscribeUser(delegate: AUIRtmUserRespObserver) { + proxy.registerUserRespObserver(delegate) } - fun unsubscribeUser(delegate: AUIRtmUserProxyDelegate) { - proxy.unsubscribeUser(delegate) + fun unsubscribeUser(delegate: AUIRtmUserRespObserver) { + proxy.unRegisterUserRespObserver(delegate) } fun subscribe(channelType:RtmChannelType,channelName: String, token: String, completion: (AUIRtmException?) -> Unit) { diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmMsgProxy.kt b/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmMsgProxy.kt index b350504f..530c48ac 100644 --- a/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmMsgProxy.kt +++ b/Android/auikit-service/src/main/java/io/agora/auikit/service/rtm/AUIRtmMsgProxy.kt @@ -10,7 +10,7 @@ import io.agora.rtm2.StorageEvent import io.agora.rtm2.TopicEvent import org.json.JSONObject -interface AUIRtmErrorProxyDelegate { +interface AUIRtmErrorRespObserver { /** token过期 */ @@ -22,15 +22,15 @@ interface AUIRtmErrorProxyDelegate { /** 收到的KV为空 */ - fun onMsgRecvEmpty(channelName: String) {} + fun onMsgReceiveEmpty(channelName: String) {} } -interface AUIRtmMsgProxyDelegate { +interface AUIRtmMsgRespObserver { fun onMsgDidChanged(channelName: String, key: String, value: Any) - fun onMsgRecvEmpty(channelName: String) {} + fun onMsgReceiveEmpty(channelName: String) {} } -interface AUIRtmUserProxyDelegate { +interface AUIRtmUserRespObserver { fun onUserSnapshotRecv(channelName: String, userId: String, userList: List>) fun onUserDidJoined(channelName: String, userId: String, userInfo: Map) fun onUserDidLeaved(channelName: String, userId: String, userInfo: Map) @@ -40,49 +40,49 @@ interface AUIRtmUserProxyDelegate { class AUIRtmMsgProxy : RtmEventListener { var originEventListeners: RtmEventListener? = null - private val msgDelegates: MutableMap> = mutableMapOf() + private val msgRespObservers: MutableMap> = mutableMapOf() private val msgCacheAttr: MutableMap> = mutableMapOf() - private val userDelegates: MutableList = mutableListOf() - private val errorDelegates: MutableList = mutableListOf() + private val userRespObservers: MutableList = mutableListOf() + private val errorRespObservers: MutableList = mutableListOf() var skipMetaEmpty = 0 fun cleanCache(channelName: String) { msgCacheAttr.remove(channelName) } - fun subscribeMsg(channelName: String, itemKey: String, delegate: AUIRtmMsgProxyDelegate) { + fun registerMsgRespObserver(channelName: String, itemKey: String, observer: AUIRtmMsgRespObserver) { val key = "${channelName}__${itemKey}" - val delegates = msgDelegates[key] ?: ArrayList() - delegates.add(delegate) - msgDelegates[key] = delegates + val observers = msgRespObservers[key] ?: ArrayList() + observers.add(observer) + msgRespObservers[key] = observers } - fun unsubscribeMsg(channelName: String, itemKey: String, delegate: AUIRtmMsgProxyDelegate) { + fun unRegisterMsgRespObserver(channelName: String, itemKey: String, observer: AUIRtmMsgRespObserver) { val key = "${channelName}__${itemKey}" - val delegates = msgDelegates[key] ?: return - delegates.remove(delegate) + val observers = msgRespObservers[key] ?: return + observers.remove(observer) } - fun subscribeUser(delegate: AUIRtmUserProxyDelegate) { - if (userDelegates.contains(delegate)) { + fun registerUserRespObserver(observer: AUIRtmUserRespObserver) { + if (userRespObservers.contains(observer)) { return } - userDelegates.add(delegate) + userRespObservers.add(observer) } - fun unsubscribeUser(delegate: AUIRtmUserProxyDelegate) { - userDelegates.remove(delegate) + fun unRegisterUserRespObserver(observer: AUIRtmUserRespObserver) { + userRespObservers.remove(observer) } - fun subscribeError(channelName: String, delegate: AUIRtmErrorProxyDelegate) { - if (errorDelegates.contains(delegate)) { + fun registerErrorRespObserver(observer: AUIRtmErrorRespObserver) { + if (errorRespObservers.contains(observer)) { return } - errorDelegates.add(delegate) + errorRespObservers.add(observer) } - fun unsubscribeError(channelName: String, delegate: AUIRtmErrorProxyDelegate) { - errorDelegates.remove(delegate) + fun unRegisterErrorRespObserver(observer: AUIRtmErrorRespObserver) { + errorRespObservers.remove(observer) } override fun onStorageEvent(event: StorageEvent?) { @@ -94,9 +94,9 @@ class AUIRtmMsgProxy : RtmEventListener { skipMetaEmpty -- return } - val delegateKey = "${event.target}__" - msgDelegates[delegateKey]?.forEach { delegate -> - delegate.onMsgRecvEmpty(event.target) + val handlerKey = "${event.target}__" + msgRespObservers[handlerKey]?.forEach { handler -> + handler.onMsgReceiveEmpty(event.target) } return } @@ -107,10 +107,10 @@ class AUIRtmMsgProxy : RtmEventListener { return@forEach } cache[item.key] = item.value - val delegateKey = "${event.target}__${item.key}" + val handlerKey = "${event.target}__${item.key}" Log.d("rtm_event", "onStorageEvent: key event: ${item.key} \n value: ${item.value}") - msgDelegates[delegateKey]?.forEach { delegate -> - delegate.onMsgDidChanged(event.target, item.key, item.value) + msgRespObservers[handlerKey]?.forEach { handler -> + handler.onMsgDidChanged(event.target, item.key, item.value) } } msgCacheAttr[cacheKey] = cache @@ -127,17 +127,17 @@ class AUIRtmMsgProxy : RtmEventListener { Log.d("rtm_presence_event", "onPresenceEvent Map: $map") when(event.type){ RtmConstants.RtmPresenceEventType.REMOTE_JOIN -> - userDelegates.forEach { delegate -> - delegate.onUserDidJoined(event.channelName, event.publisher ?: "", map) + userRespObservers.forEach { handler -> + handler.onUserDidJoined(event.channelName, event.publisher ?: "", map) } RtmConstants.RtmPresenceEventType.REMOTE_LEAVE, RtmConstants.RtmPresenceEventType.REMOTE_TIMEOUT -> - userDelegates.forEach { delegate -> - delegate.onUserDidLeaved(event.channelName, event.publisher ?: "", map) + userRespObservers.forEach { handler -> + handler.onUserDidLeaved(event.channelName, event.publisher ?: "", map) } RtmConstants.RtmPresenceEventType.REMOTE_STATE_CHANGED -> - userDelegates.forEach { delegate -> - delegate.onUserDidUpdated(event.channelName, event.publisher ?: "", map) + userRespObservers.forEach { handler -> + handler.onUserDidUpdated(event.channelName, event.publisher ?: "", map) } RtmConstants.RtmPresenceEventType.SNAPSHOT -> { val userList = arrayListOf>() @@ -157,8 +157,8 @@ class AUIRtmMsgProxy : RtmEventListener { } } Log.d("rtm_presence_event", "onPresenceEvent SNAPSHOT: $userList") - userDelegates.forEach { delegate -> - delegate.onUserSnapshotRecv(event.channelName, event.publisher ?: "", userList) + userRespObservers.forEach { handler -> + handler.onUserSnapshotRecv(event.channelName, event.publisher ?: "", userList) } } else -> { @@ -183,8 +183,8 @@ class AUIRtmMsgProxy : RtmEventListener { val messageType = json?.get("messageType").toString() originEventListeners?.onMessageEvent(event) val delegateKey = "${event.channelName}__$messageType" - msgDelegates[delegateKey]?.forEach { delegate -> - str?.let { delegate.onMsgDidChanged(event.channelName, messageType, it) } + msgRespObservers[delegateKey]?.forEach { handler -> + str?.let { handler.onMsgDidChanged(event.channelName, messageType, it) } } } @@ -205,7 +205,7 @@ class AUIRtmMsgProxy : RtmEventListener { ) { Log.d("rtm_event", "rtm -- connect state change: $state, reason: $reason") - errorDelegates.forEach { + errorRespObservers.forEach { it.onConnectionStateChanged(channelName, RtmConstants.RtmConnectionState.getValue(state), RtmConstants.RtmConnectionChangeReason.getValue(reason)) } } @@ -213,7 +213,7 @@ class AUIRtmMsgProxy : RtmEventListener { override fun onTokenPrivilegeWillExpire(channelName: String?) { originEventListeners?.onTokenPrivilegeWillExpire(channelName) if(channelName?.isNotEmpty() == true){ - errorDelegates.forEach { + errorRespObservers.forEach { it.onTokenPrivilegeWillExpire(channelName) } } diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/utils/DelegateHelper.java b/Android/auikit-service/src/main/java/io/agora/auikit/utils/DelegateHelper.java deleted file mode 100644 index c3651462..00000000 --- a/Android/auikit-service/src/main/java/io/agora/auikit/utils/DelegateHelper.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.agora.auikit.utils; - -import android.os.Handler; -import android.os.Looper; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class DelegateHelper { - - private final List delegateList = Collections.synchronizedList(new ArrayList<>()); - private final Handler mainHandler = new Handler(Looper.getMainLooper()); - - public void bindDelegate(@Nullable Delegate delegate) { - if (delegate == null) { - return; - } - delegateList.add(delegate); - } - - public void unBindDelegate(@Nullable Delegate delegate) { - if (delegate == null) { - return; - } - delegateList.remove(delegate); - } - - public void unBindAll() { - delegateList.clear(); - mainHandler.removeCallbacksAndMessages(null); - } - - public void notifyDelegate(@NonNull DelegateRunnable runnable) { - for (Delegate delegate : delegateList) { - if (mainHandler.getLooper().getThread() != Thread.currentThread()) { - mainHandler.post(() -> runnable.run(delegate)); - } else { - runnable.run(delegate); - } - } - } - - public interface DelegateRunnable { - void run(Delegate delegate); - } - -} diff --git a/Android/auikit-service/src/main/java/io/agora/auikit/utils/ObservableHelper.java b/Android/auikit-service/src/main/java/io/agora/auikit/utils/ObservableHelper.java new file mode 100644 index 00000000..8fd72b22 --- /dev/null +++ b/Android/auikit-service/src/main/java/io/agora/auikit/utils/ObservableHelper.java @@ -0,0 +1,51 @@ +package io.agora.auikit.utils; + +import android.os.Handler; +import android.os.Looper; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class ObservableHelper { + + private final List eventHandlerList = Collections.synchronizedList(new ArrayList<>()); + private final Handler mainHandler = new Handler(Looper.getMainLooper()); + + public void subscribeEvent(@Nullable EventHandler eventHandler) { + if (eventHandler == null) { + return; + } + eventHandlerList.add(eventHandler); + } + + public void unSubscribeEvent(@Nullable EventHandler eventHandler) { + if (eventHandler == null) { + return; + } + eventHandlerList.remove(eventHandler); + } + + public void unSubscribeAll() { + eventHandlerList.clear(); + mainHandler.removeCallbacksAndMessages(null); + } + + public void notifyEventHandlers(@NonNull EventHandlerRunnable runnable) { + for (EventHandler eventHandler : eventHandlerList) { + if (mainHandler.getLooper().getThread() != Thread.currentThread()) { + mainHandler.post(() -> runnable.run(eventHandler)); + } else { + runnable.run(eventHandler); + } + } + } + + public interface EventHandlerRunnable { + void run(EventHandler eventHandler); + } + +} diff --git a/Android/doc/AUIKit-Service.md b/Android/doc/AUIKit-Service.md index 898ff54b..e168c4d9 100644 --- a/Android/doc/AUIKit-Service.md +++ b/Android/doc/AUIKit-Service.md @@ -8,7 +8,7 @@ AUIKit Service provides a set of common service interfaces that can be used for ## Directory Structure ``` service interface: -auikit-ui/src/main/java/io/agora/auikit/service +auikit-service/src/main/java/io/agora/auikit/service ├── IAUICommonService.java basic service abstract class ├── IAUIRoomManager.java room management ├── IAUIUserService.java user management @@ -20,7 +20,7 @@ auikit-ui/src/main/java/io/agora/auikit/service └── callback callback interface data structure: -auikit-ui/src/main/java/io/agora/auikit/model +auikit-service/src/main/java/io/agora/auikit/model ├── AUICommonConfig.java public configuration class ├── AUIRoomConfig.java room configuration ├── AUIRoomContext.java room context @@ -43,7 +43,7 @@ auikit-ui/src/main/java/io/agora/auikit/model ### **`service interface`** -* **Basic service abstract class ->** [IAUICommonService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUICommonService.java) +* **Basic service abstract class ->** [IAUICommonService](../auikit-service/src/main/java/io/agora/auikit/service/IAUICommonService.java) | method | annotation | | :- | :- | | bindRespDelegate | Bind response events | @@ -54,8 +54,8 @@ auikit-ui/src/main/java/io/agora/auikit/model * **Room Management** -Room management abstract class -> [IAUIRoomManager](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) -Agora room management class -> [AUIRoomManagerImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt) +Room management abstract class -> [IAUIRoomManager](../auikit-service/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) +Agora room management class -> [AUIRoomManagerImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt) | method | annotation | | :- | :- | @@ -65,7 +65,7 @@ Agora room management class -> [AUIRoomManagerImpl](../auikit-ui/src/main/java/i | exitRoom | Exit the room (listener call) | | getRoomInfoList | Get the detailed information of the specified room id list, if the room id list is empty, get the information of all rooms | -Room information callback interface -> [IAUIRoomManager.AUIRoomRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) +Room information callback interface -> [IAUIRoomManager.AUIRoomRespObserver](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) | method | annotation | | :- | :- | @@ -74,8 +74,8 @@ Room information callback interface -> [IAUIRoomManager.AUIRoomRespDelegate](../ * **User Management** -User management abstract class -> [IAUIUserService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIUserService.java) -Agora user management class -> [AUIUserServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt) +User management abstract class -> [IAUIUserService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIUserService.java) +Agora user management class -> [AUIUserServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt) | method | annotation | | :- | :- | @@ -84,7 +84,7 @@ Agora user management class -> [AUIUserServiceImpl](../auikit-ui/src/main/java/i | muteUserAudio | Mute/unmute yourself | | muteUserVideo | Forbid/unban camera for yourself | -User information callback interface -> [IAUIUserService.AUIUserRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIUserService.java) +User information callback interface -> [IAUIUserService.AUIUserRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIUserService.java) | method | annotation | | :- | :- | @@ -97,8 +97,8 @@ User information callback interface -> [IAUIUserService.AUIUserRespDelegate](../ * **Wheat bit management** -Wheat seat management abstract class -> [IAUIMicSeatService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) -Agora wheat seat management class -> [AUIMicSeatServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt) +Wheat seat management abstract class -> [IAUIMicSeatService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) +Agora wheat seat management class -> [AUIMicSeatServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt) | method | annotation | | :- | :- | @@ -112,7 +112,7 @@ Agora wheat seat management class -> [AUIMicSeatServiceImpl](../auikit-ui/src/ma | closeSeat | Block/unblock a seat (call by the homeowner) | | getMicSeatInfo | Get the specified microphone seat information | -Microphone information callback interface -> [IAUIMicSeatService.AUIMicSeatRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) +Microphone information callback interface -> [IAUIMicSeatService.AUIMicSeatRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) | method | annotation | | :- | :- | @@ -125,8 +125,8 @@ Microphone information callback interface -> [IAUIMicSeatService.AUIMicSeatRespD * **Voice Management** -Juke management abstract class -> [IAUIJukeboxService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) -Agora juke management class -> [AUIJukeboxServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt) +Juke management abstract class -> [IAUIJukeboxService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) +Agora juke management class -> [AUIJukeboxServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt) | method | annotation | | :- | :- | @@ -138,7 +138,7 @@ Agora juke management class -> [AUIJukeboxServiceImpl](../auikit-ui/src/main/jav | pingSong | Top songs | | updatePlayStatus | Update Play Status | -Juke information callback interface -> [IAUIJukeboxService.AUIJukeboxRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) +Juke information callback interface -> [IAUIJukeboxService.AUIJukeboxRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) | method | annotation | | :- | :- | @@ -149,8 +149,8 @@ Juke information callback interface -> [IAUIJukeboxService.AUIJukeboxRespDelegat * **Chorus Management** -Chorus management abstract class -> [IAUIChorusService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIChorusService.java) -Agora chorus management class -> [AUIChorusServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt) +Chorus management abstract class -> [IAUIChorusService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java) +Agora chorus management class -> [AUIChorusServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt) | method | annotation | | :- | :- | @@ -159,7 +159,7 @@ Agora chorus management class -> [AUIChorusServiceImpl](../auikit-ui/src/main/ja | leaveChorus | leave the chorus | | switchSingerRole | switch role | -Chorus information callback interface -> [IAUIChorusService.AUIChorusRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIChorusService.java) +Chorus information callback interface -> [IAUIChorusService.AUIChorusRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java) | method | annotation | | :- | :- | @@ -170,8 +170,8 @@ Chorus information callback interface -> [IAUIChorusService.AUIChorusRespDelegat * **Play Management** -Play management abstract class -> [IAUIMusicPlayerService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) -Agora playback management class -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt) +Play management abstract class -> [IAUIMusicPlayerService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) +Agora playback management class -> [AUIMusicPlayerServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt) | method | annotation | | :- | :- | @@ -192,7 +192,7 @@ Agora playback management class -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/ | effectProperties | sound mapping key | | enableEarMonitoring | Ear monitor on and off | -Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) +Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) | method | annotation | | :- | :- | @@ -207,17 +207,17 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe ### **`Data Structure`** -* **Common configuration class ->** [AUICommonConfig](../auikit-ui/src/main/java/io/agora/auikit/model/AUICommonConfig.java) +* **Common configuration class ->** [AUICommonConfig](../auikit-service/src/main/java/io/agora/auikit/model/AUICommonConfig.java) | field | comment | | :- | :- | | context | Android context | -| appId | Agora APP ID | +| host | Domain name of the business server | | userId | local user Id | | userName | local username | | userAvatar | local user avatar | -* **Room configuration information ->** [AUIRoomConfig](../auikit-ui/src/main/java/io/agora/auikit/model/AUIRoomConfig.java) +* **Room configuration information ->** [AUIRoomConfig](../auikit-service/src/main/java/io/agora/auikit/model/AUIRoomConfig.java) | field | comment | | :- | :- | @@ -226,15 +226,17 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | ktvChorusChannelName | channel name used by chorus | | tokenMap | All token tables used internally | -* **Room Context ->** [AUIRoomContext](../auikit-ui/src/main/java/io/agora/auikit/model/AUIRoomContext.java) +* **Room Context ->** [AUIRoomContext](../auikit-service/src/main/java/io/agora/auikit/model/AUIRoomContext.java) | field | comment | | :- | :- | | currentUserInfo | Cached local user information | -| roomConfig | room configuration information | +| appId | Agora APP ID | +| mCommonConfig | Room common config | +| roomConfigMap | room configuration information | | roomInfoMap | List of all rooms joined | -* **Create room information ->** [AUICreateRoomInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUICreateRoomInfo.java) +* **Create room information ->** [AUICreateRoomInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUICreateRoomInfo.java) | field | comment | | :- | :- | @@ -243,7 +245,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | seatCount | Number of seats | | password | Room password | -* **Room Information ->** [AUIRoomInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIRoomInfo.java) +* **Room Information ->** [AUIRoomInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIRoomInfo.java) | field | comment | | :- | :- | @@ -252,7 +254,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | onlineUsers | Number of people in the room | | createTime | room creation time | -* **Basic user information ->** [AUIUserThumbnailInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIUserThumbnailInfo.java) +* **Basic user information ->** [AUIUserThumbnailInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIUserThumbnailInfo.java) | field | comment | | :- | :- | @@ -260,7 +262,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | userName | username | | userAvatar | User Avatar | -* **Complete user information ->** [AUIUserInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIUserInfo.java) +* **Complete user information ->** [AUIUserInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIUserInfo.java) | field | comment | | :- | :- | @@ -270,7 +272,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | muteAudio | Mute or not | | muteVideo | Whether to turn off the video state | -* **Microseat Information ->** [AUIMicSeatInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIMicSeatInfo.java) +* **Microseat Information ->** [AUIMicSeatInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIMicSeatInfo.java) | field | comment | | :- | :- | @@ -280,7 +282,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | muteAudio | Mic disable sound, 0: no, 1: yes | | muteVideo | Mic disable video, 0: no, 1: yes | -* **Sing song information ->** [AUIMusicModel](../auikit-ui/src/main/java/io/agora/auikit/model/AUIMusicModel.java) +* **Sing song information ->** [AUIMusicModel](../auikit-service/src/main/java/io/agora/auikit/model/AUIMusicModel.java) | field | comment | | :- | :- | @@ -293,7 +295,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | musicUrl | song url, mcc is empty | | lrcUrl | lyrics url, mcc is empty | -* **Selected song information ->** [AUIChooseMusicModel](../auikit-ui/src/main/java/io/agora/auikit/model/AUIChooseMusicModel.java) +* **Selected song information ->** [AUIChooseMusicModel](../auikit-service/src/main/java/io/agora/auikit/model/AUIChooseMusicModel.java) | field | comment | | :- | :- | @@ -311,7 +313,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | status | Playing status, 0 is waiting to play, 1 is playing | -* ** Chorus information ->** [AUIChoristerModel](../auikit-ui/src/main/java/io/agora/auikit/model/AUIChoristerModel.java) +* ** Chorus information ->** [AUIChoristerModel](../auikit-service/src/main/java/io/agora/auikit/model/AUIChoristerModel.java) | field | comment | | :- | :- | @@ -319,7 +321,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | chorusSongNo | Chorus singing a song | | owner | chorus information | -* **Play audio information ->** [AUIEffectVoiceInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIEffectVoiceInfo.java) +* **Play audio information ->** [AUIEffectVoiceInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIEffectVoiceInfo.java) | field | comment | | :- | :- | @@ -328,7 +330,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | resId | icon resource Id | | name | name resource Id | -* **Play loading music configuration ->** [AUILoadMusicConfiguration](../auikit-ui/src/main/java/io/agora/auikit/model/AUILoadMusicConfiguration.java) +* **Play loading music configuration ->** [AUILoadMusicConfiguration](../auikit-service/src/main/java/io/agora/auikit/model/AUILoadMusicConfiguration.java) | field | comment | | :- | :- | @@ -336,7 +338,7 @@ Chorus information callback interface -> [IAUIMusicPlayerService.AUIPlayerRespDe | mainSingerUid | main singer user id | | loadMusicMode | load music mode, 0: LOAD Music Only, 1: audience, 2: lead singer | -* **Play music configuration information ->** [AUIMusicSettingInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIMusicSettingInfo.java) +* **Play music configuration information ->** [AUIMusicSettingInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIMusicSettingInfo.java) | field | comment | | :- | :- | diff --git a/Android/doc/AUIKit-Service.zh.md b/Android/doc/AUIKit-Service.zh.md index cd718061..4c902ecb 100644 --- a/Android/doc/AUIKit-Service.zh.md +++ b/Android/doc/AUIKit-Service.zh.md @@ -8,7 +8,7 @@ AUIKit Service提供一套通用的服务接口,可用于数据交互。这套 ## 目录结构 ``` service接口: -auikit-ui/src/main/java/io/agora/auikit/service +auikit-service/src/main/java/io/agora/auikit/service ├── IAUICommonService.java 基础服务抽象类 ├── IAUIRoomManager.java 房间管理 ├── IAUIUserService.java 用户管理 @@ -20,7 +20,7 @@ auikit-ui/src/main/java/io/agora/auikit/service └── callback 回调接口 数据结构: -auikit-ui/src/main/java/io/agora/auikit/model +auikit-service/src/main/java/io/agora/auikit/model ├── AUICommonConfig.java 公共配置类 ├── AUIRoomConfig.java 房间配置 ├── AUIRoomContext.java 房间上下文 @@ -43,7 +43,7 @@ auikit-ui/src/main/java/io/agora/auikit/model ### **`service接口`** -* **基础服务抽象类 ->** [IAUICommonService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUICommonService.java) +* **基础服务抽象类 ->** [IAUICommonService](../auikit-service/src/main/java/io/agora/auikit/service/IAUICommonService.java) | 方法 | 注释 | | :- | :- | | bindRespDelegate | 绑定响应事件 | @@ -54,8 +54,8 @@ auikit-ui/src/main/java/io/agora/auikit/model * **房间管理** -房间管理抽象类 -> [IAUIRoomManager](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) -Agora房间管理类 -> [AUIRoomManagerImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt) +房间管理抽象类 -> [IAUIRoomManager](../auikit-service/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) +Agora房间管理类 -> [AUIRoomManagerImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIRoomServiceImpl.kt) | 方法 | 注释 | | :- | :- | @@ -65,7 +65,7 @@ Agora房间管理类 -> [AUIRoomManagerImpl](../auikit-ui/src/main/java/io/agora | exitRoom | 退出房间(听众调用) | | getRoomInfoList | 获取指定房间id列表的详细信息,如果房间id列表为空,则获取所有房间的信息 | -房间信息回调接口 -> [IAUIRoomManager.AUIRoomRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) +房间信息回调接口 -> [IAUIRoomManager.AUIRoomRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIRoomManager.java) | 方法 | 注释 | | :- | :- | @@ -74,8 +74,8 @@ Agora房间管理类 -> [AUIRoomManagerImpl](../auikit-ui/src/main/java/io/agora * **用户管理** -用户管理抽象类 -> [IAUIUserService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIUserService.java) -Agora用户管理类 -> [AUIUserServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt) +用户管理抽象类 -> [IAUIUserService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIUserService.java) +Agora用户管理类 -> [AUIUserServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIUserServiceImpl.kt) | 方法 | 注释 | | :- | :- | @@ -84,7 +84,7 @@ Agora用户管理类 -> [AUIUserServiceImpl](../auikit-ui/src/main/java/io/agora | muteUserAudio | 对自己静音/解除静音 | | muteUserVideo | 对自己禁摄像头/解禁摄像头 | -用户信息回调接口 -> [IAUIUserService.AUIUserRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIUserService.java) +用户信息回调接口 -> [IAUIUserService.AUIUserRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIUserService.java) | 方法 | 注释 | | :- | :- | @@ -97,8 +97,8 @@ Agora用户管理类 -> [AUIUserServiceImpl](../auikit-ui/src/main/java/io/agora * **麦位管理** -麦位管理抽象类 -> [IAUIMicSeatService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) -Agora麦位管理类 -> [AUIMicSeatServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt) +麦位管理抽象类 -> [IAUIMicSeatService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) +Agora麦位管理类 -> [AUIMicSeatServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMicSeatServiceImpl.kt) | 方法 | 注释 | | :- | :- | @@ -112,7 +112,7 @@ Agora麦位管理类 -> [AUIMicSeatServiceImpl](../auikit-ui/src/main/java/io/ag | closeSeat | 封禁/解禁某个麦位(房主调用) | | getMicSeatInfo | 获取指定麦位信息 | -麦位信息回调接口 -> [IAUIMicSeatService.AUIMicSeatRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) +麦位信息回调接口 -> [IAUIMicSeatService.AUIMicSeatRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMicSeatService.java) | 方法 | 注释 | | :- | :- | @@ -125,8 +125,8 @@ Agora麦位管理类 -> [AUIMicSeatServiceImpl](../auikit-ui/src/main/java/io/ag * **点唱管理** -点唱管理抽象类 -> [IAUIJukeboxService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) -Agora点唱管理类 -> [AUIJukeboxServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt) +点唱管理抽象类 -> [IAUIJukeboxService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) +Agora点唱管理类 -> [AUIJukeboxServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIJukeboxServiceImpl.kt) | 方法 | 注释 | | :- | :- | @@ -138,7 +138,7 @@ Agora点唱管理类 -> [AUIJukeboxServiceImpl](../auikit-ui/src/main/java/io/ag | pingSong | 置顶歌曲 | | updatePlayStatus | 更新播放状态 | -点唱信息回调接口 -> [IAUIJukeboxService.AUIJukeboxRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) +点唱信息回调接口 -> [IAUIJukeboxService.AUIJukeboxRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIJukeboxService.java) | 方法 | 注释 | | :- | :- | @@ -149,8 +149,8 @@ Agora点唱管理类 -> [AUIJukeboxServiceImpl](../auikit-ui/src/main/java/io/ag * **合唱管理** -合唱管理抽象类 -> [IAUIChorusService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIChorusService.java) -Agora合唱管理类 -> [AUIChorusServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt) +合唱管理抽象类 -> [IAUIChorusService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java) +Agora合唱管理类 -> [AUIChorusServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIChorusServiceImpl.kt) | 方法 | 注释 | | :- | :- | @@ -159,7 +159,7 @@ Agora合唱管理类 -> [AUIChorusServiceImpl](../auikit-ui/src/main/java/io/ago | leaveChorus | 退出合唱 | | switchSingerRole | 切换角色 | -合唱信息回调接口 -> [IAUIChorusService.AUIChorusRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIChorusService.java) +合唱信息回调接口 -> [IAUIChorusService.AUIChorusRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIChorusService.java) | 方法 | 注释 | | :- | :- | @@ -170,8 +170,8 @@ Agora合唱管理类 -> [AUIChorusServiceImpl](../auikit-ui/src/main/java/io/ago * **播放管理** -播放管理抽象类 -> [IAUIMusicPlayerService](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) -Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt) +播放管理抽象类 -> [IAUIMusicPlayerService](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) +Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-service/src/main/java/io/agora/auikit/service/imp/AUIMusicPlayerServiceImpl.kt) | 方法 | 注释 | | :- | :- | @@ -192,7 +192,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | effectProperties | 音效映射key | | enableEarMonitoring | 耳返开启关闭 | -合唱信息回调接口 -> [IAUIMusicPlayerService.AUIPlayerRespDelegate](../auikit-ui/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) +合唱信息回调接口 -> [IAUIMusicPlayerService.AUIPlayerRespObserver](../auikit-service/src/main/java/io/agora/auikit/service/IAUIMusicPlayerService.java) | 方法 | 注释 | | :- | :- | @@ -207,17 +207,17 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i ### **`数据结构`** -* **公共配置类 ->** [AUICommonConfig](../auikit-ui/src/main/java/io/agora/auikit/model/AUICommonConfig.java) +* **公共配置类 ->** [AUICommonConfig](../auikit-service/src/main/java/io/agora/auikit/model/AUICommonConfig.java) | 字段 | 注释 | | :- | :- | | context | Android上下文 | -| appId | Agora APP ID | +| host | 业务服务器域名 | | userId | 本地用户Id | | userName | 本地用户名 | | userAvatar | 本地用户头像 | -* **房间配置信息 ->** [AUIRoomConfig](../auikit-ui/src/main/java/io/agora/auikit/model/AUIRoomConfig.java) +* **房间配置信息 ->** [AUIRoomConfig](../auikit-service/src/main/java/io/agora/auikit/model/AUIRoomConfig.java) | 字段 | 注释 | | :- | :- | @@ -226,15 +226,17 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | ktvChorusChannelName | 合唱所使用频道名 | | tokenMap | 内部使用到的所有token表 | -* **房间上下文 ->** [AUIRoomContext](../auikit-ui/src/main/java/io/agora/auikit/model/AUIRoomContext.java) +* **房间上下文 ->** [AUIRoomContext](../auikit-service/src/main/java/io/agora/auikit/model/AUIRoomContext.java) | 字段 | 注释 | | :- | :- | | currentUserInfo | 缓存的本地用户信息 | -| roomConfig | 房间配置信息 | +| appId | Agora APP ID | +| mCommonConfig | 所有房间公用配置 | +| roomConfigMap | 各个房间配置信息 | | roomInfoMap | 加入的所有房间列表 | -* **创建房间信息 ->** [AUICreateRoomInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUICreateRoomInfo.java) +* **创建房间信息 ->** [AUICreateRoomInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUICreateRoomInfo.java) | 字段 | 注释 | | :- | :- | @@ -243,7 +245,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | seatCount | 麦位个数 | | password | 房间密码 | -* **房间信息 ->** [AUIRoomInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIRoomInfo.java) +* **房间信息 ->** [AUIRoomInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIRoomInfo.java) | 字段 | 注释 | | :- | :- | @@ -252,7 +254,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | onlineUsers | 房间内人数 | | createTime | 房间创建时间 | -* **基础用户信息 ->** [AUIUserThumbnailInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIUserThumbnailInfo.java) +* **基础用户信息 ->** [AUIUserThumbnailInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIUserThumbnailInfo.java) | 字段 | 注释 | | :- | :- | @@ -260,7 +262,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | userName | 用户名 | | userAvatar | 用户头像 | -* **完整用户信息 ->** [AUIUserInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIUserInfo.java) +* **完整用户信息 ->** [AUIUserInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIUserInfo.java) | 字段 | 注释 | | :- | :- | @@ -270,7 +272,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | muteAudio | 是否静音状态 | | muteVideo | 是否关闭视频状态 | -* **麦位信息 ->** [AUIMicSeatInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIMicSeatInfo.java) +* **麦位信息 ->** [AUIMicSeatInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIMicSeatInfo.java) | 字段 | 注释 | | :- | :- | @@ -280,7 +282,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | muteAudio | 麦位禁用声音,0:否,1:是 | | muteVideo | 麦位禁用视频,0:否,1:是 | -* **点唱歌曲信息 ->** [AUIMusicModel](../auikit-ui/src/main/java/io/agora/auikit/model/AUIMusicModel.java) +* **点唱歌曲信息 ->** [AUIMusicModel](../auikit-service/src/main/java/io/agora/auikit/model/AUIMusicModel.java) | 字段 | 注释 | | :- | :- | @@ -293,7 +295,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | musicUrl | 歌曲url,mcc则为空 | | lrcUrl | 歌词url,mcc则为空 | -* **已点歌曲信息 ->** [AUIChooseMusicModel](../auikit-ui/src/main/java/io/agora/auikit/model/AUIChooseMusicModel.java) +* **已点歌曲信息 ->** [AUIChooseMusicModel](../auikit-service/src/main/java/io/agora/auikit/model/AUIChooseMusicModel.java) | 字段 | 注释 | | :- | :- | @@ -311,7 +313,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | status | 播放状态,0 待播放,1 播放中 | -* **合唱者信息 ->** [AUIChoristerModel](../auikit-ui/src/main/java/io/agora/auikit/model/AUIChoristerModel.java) +* **合唱者信息 ->** [AUIChoristerModel](../auikit-service/src/main/java/io/agora/auikit/model/AUIChoristerModel.java) | 字段 | 注释 | | :- | :- | @@ -319,7 +321,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | chorusSongNo | 合唱者演唱歌曲 | | owner | 合唱者信息 | -* **播放音效信息 ->** [AUIEffectVoiceInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIEffectVoiceInfo.java) +* **播放音效信息 ->** [AUIEffectVoiceInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIEffectVoiceInfo.java) | 字段 | 注释 | | :- | :- | @@ -328,7 +330,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | resId | 图标资源Id | | name | 名称资源Id | -* **播放加载音乐配置 ->** [AUILoadMusicConfiguration](../auikit-ui/src/main/java/io/agora/auikit/model/AUILoadMusicConfiguration.java) +* **播放加载音乐配置 ->** [AUILoadMusicConfiguration](../auikit-service/src/main/java/io/agora/auikit/model/AUILoadMusicConfiguration.java) | 字段 | 注释 | | :- | :- | @@ -336,7 +338,7 @@ Agora播放管理类 -> [AUIMusicPlayerServiceImpl](../auikit-ui/src/main/java/i | mainSingerUid | 主唱用户id | | loadMusicMode | 加载音乐模式,0:LOAD Music Only,1:观众,2:主唱 | -* **播放音乐配置信息 ->** [AUIMusicSettingInfo](../auikit-ui/src/main/java/io/agora/auikit/model/AUIMusicSettingInfo.java) +* **播放音乐配置信息 ->** [AUIMusicSettingInfo](../auikit-service/src/main/java/io/agora/auikit/model/AUIMusicSettingInfo.java) | 字段 | 注释 | | :- | :- | diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e445688..643f8f16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ English | [中文](CHANGELOG.zh.md) +## [0.5.2](https://github.com/AgoraIO-Community/AUIKit/releases/tag/0.5.2) +- appId removed from AUICommonConfig as an attribute of AUIRoomContext +- [iOS]Change all methods in AUIRoomManagerRespDelegate to optional +- [Android]Change the delegate interface to observer + ## [0.5.1](https://github.com/AgoraIO-Community/AUIKit/releases/tag/0.5.1) - [iOS]Fix subspec redundancy dependency issue - Fix other remaining bugs diff --git a/CHANGELOG.zh.md b/CHANGELOG.zh.md index 447b42c7..7c979d3e 100644 --- a/CHANGELOG.zh.md +++ b/CHANGELOG.zh.md @@ -1,6 +1,11 @@ [English](CHANGELOG.md) | 中文 +## [0.5.2](https://github.com/AgoraIO-Community/AUIKit/releases/tag/0.5.2) +- appId从AUICommonConfig移除,作为AUIRoomContext的属性 +- [iOS]AUIRoomManagerRespDelegate里所有方法改为optional +- [Android]将delegate接口改成observer + ## [0.5.1](https://github.com/AgoraIO-Community/AUIKit/releases/tag/0.5.1) - [iOS]修复subspec冗余依赖问题 - 剩余Bug修复 diff --git a/iOS/AUIKitCore/Sources/Core/Utils/Context/AUIRoomContext.swift b/iOS/AUIKitCore/Sources/Core/Utils/Context/AUIRoomContext.swift index c2c79c77..cf2c5816 100644 --- a/iOS/AUIKitCore/Sources/Core/Utils/Context/AUIRoomContext.swift +++ b/iOS/AUIKitCore/Sources/Core/Utils/Context/AUIRoomContext.swift @@ -9,7 +9,8 @@ import Foundation open class AUIRoomContext: NSObject { public static let shared: AUIRoomContext = AUIRoomContext() - + /// appid + public var appId: String = "" public let currentUserInfo: AUIUserThumbnailInfo = AUIUserThumbnailInfo() public var commonConfig: AUICommonConfig? { didSet { diff --git a/iOS/AUIKitCore/Sources/Service/Impl/AUIRoomManagerImpl.swift b/iOS/AUIKitCore/Sources/Service/Impl/AUIRoomManagerImpl.swift index 8db1b96d..833f1046 100644 --- a/iOS/AUIKitCore/Sources/Service/Impl/AUIRoomManagerImpl.swift +++ b/iOS/AUIKitCore/Sources/Service/Impl/AUIRoomManagerImpl.swift @@ -44,7 +44,7 @@ let kUserMuteAttrKey = "mute" private func createRtmClient() -> AgoraRtmClientKit { let rtmConfig = AgoraRtmClientConfig() rtmConfig.userId = commonConfig.userId - rtmConfig.appId = commonConfig.appId + rtmConfig.appId = AUIRoomContext.shared.appId let log = AgoraRtmLogConfig() log.filePath = NSHomeDirectory() + "/Documents/RTMLog/" rtmConfig.logConfig = log @@ -168,7 +168,7 @@ extension AUIRoomManagerImpl: AUIRtmErrorProxyDelegate { @objc public func onMsgRecvEmpty(channelName: String) { self.respDelegates.allObjects.forEach { obj in guard let delegate = obj as? AUIRoomManagerRespDelegate else {return} - delegate.onRoomDestroy(roomId: channelName) + delegate.onRoomDestroy?(roomId: channelName) } } @@ -180,7 +180,7 @@ extension AUIRoomManagerImpl: AUIRtmErrorProxyDelegate { } for obj in self.respDelegates.allObjects { - (obj as? AUIRoomManagerRespDelegate)?.onRoomUserBeKicked(roomId: channelName, userId: AUIRoomContext.shared.currentUserInfo.userId) + (obj as? AUIRoomManagerRespDelegate)?.onRoomUserBeKicked?(roomId: channelName, userId: AUIRoomContext.shared.currentUserInfo.userId) } } } diff --git a/iOS/AUIKitCore/Sources/Service/Model/AUIRoomConfig.swift b/iOS/AUIKitCore/Sources/Service/Model/AUIRoomConfig.swift index ef21e93f..915c10aa 100644 --- a/iOS/AUIKitCore/Sources/Service/Model/AUIRoomConfig.swift +++ b/iOS/AUIKitCore/Sources/Service/Model/AUIRoomConfig.swift @@ -8,8 +8,6 @@ import Foundation open class AUICommonConfig: NSObject { - /// appid - public var appId: String = "" /// 网络请求域名 public var host: String = "https://uikit-voiceroom-staging.bj2.agoralab.co" diff --git a/iOS/AUIKitCore/Sources/Service/Protocol/AUIRoomManagerDelegate.swift b/iOS/AUIKitCore/Sources/Service/Protocol/AUIRoomManagerDelegate.swift index fed0c1fd..7446978e 100644 --- a/iOS/AUIKitCore/Sources/Service/Protocol/AUIRoomManagerDelegate.swift +++ b/iOS/AUIKitCore/Sources/Service/Protocol/AUIRoomManagerDelegate.swift @@ -62,28 +62,28 @@ public protocol AUIRoomManagerDelegate: NSObjectProtocol { } /// 房间操作对应的响应 -public protocol AUIRoomManagerRespDelegate: NSObjectProtocol { +@objc public protocol AUIRoomManagerRespDelegate: NSObjectProtocol { /// 房间被销毁的回调 /// - Parameter roomId: 房间id - func onRoomDestroy(roomId: String) + @objc optional func onRoomDestroy(roomId: String) /// 房间信息变更回调 /// - Parameters: /// - roomId: 房间id /// - roomInfo: 房间信息 - func onRoomInfoChange(roomId: String, roomInfo: AUIRoomInfo) + @objc optional func onRoomInfoChange(roomId: String, roomInfo: AUIRoomInfo) /// Description 房间公告发生变更 /// - Parameters: /// - roomId: 房间id /// - announcement: 公告变更内容 - func onRoomAnnouncementChange(roomId: String, announcement: String) + @objc optional func onRoomAnnouncementChange(roomId: String, announcement: String) /// Description 房间用户被踢出房间 /// /// - Parameters: /// - roomId: 房间id /// - userId: 用户id - func onRoomUserBeKicked(roomId: String,userId: String) + @objc optional func onRoomUserBeKicked(roomId: String,userId: String) } diff --git a/iOS/Example/AUIKit.xcodeproj/project.pbxproj b/iOS/Example/AUIKit.xcodeproj/project.pbxproj index dd5661f9..cb76849d 100644 --- a/iOS/Example/AUIKit.xcodeproj/project.pbxproj +++ b/iOS/Example/AUIKit.xcodeproj/project.pbxproj @@ -220,8 +220,9 @@ TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - DevelopmentTeam = JDPG69R49Z; + DevelopmentTeam = YS397FG5PA; LastSwiftMigration = 0900; + ProvisioningStyle = Manual; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; @@ -561,13 +562,17 @@ baseConfigurationReference = B9CD0CD6559B14E3F0A33E06 /* Pods-AUIKit_Example.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = JDPG69R49Z; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = YS397FG5PA; INFOPLIST_FILE = AUIKit/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = io.agora.uikit.demo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = wildcard; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; }; @@ -578,13 +583,17 @@ baseConfigurationReference = 70DAF55726332003A4282BA9 /* Pods-AUIKit_Example.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - DEVELOPMENT_TEAM = JDPG69R49Z; + CODE_SIGN_STYLE = Manual; + DEVELOPMENT_TEAM = ""; + "DEVELOPMENT_TEAM[sdk=iphoneos*]" = YS397FG5PA; INFOPLIST_FILE = AUIKit/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = io.agora.uikit.demo; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; + "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = wildcard; SWIFT_SWIFT3_OBJC_INFERENCE = Default; SWIFT_VERSION = 4.0; }; diff --git a/iOS/Example/AUIKit/TestServiceViewController.swift b/iOS/Example/AUIKit/TestServiceViewController.swift index 2a9597ea..1eb95f2c 100644 --- a/iOS/Example/AUIKit/TestServiceViewController.swift +++ b/iOS/Example/AUIKit/TestServiceViewController.swift @@ -59,7 +59,7 @@ class TestServiceViewController: UIViewController, AgoraRtcEngineDelegate { @IBAction func didClickJoinRoomButton(_ sender: Any) { generateToken { config, appid in - AUIRoomContext.shared.commonConfig?.appId = appid + AUIRoomContext.shared.appId = appid self.joinRoom() } } @@ -86,14 +86,14 @@ extension TestServiceViewController { private func _rtcEngineConfig(commonConfig: AUICommonConfig) -> AgoraRtcEngineConfig { let config = AgoraRtcEngineConfig() - config.appId = commonConfig.appId + config.appId = AUIRoomContext.shared.appId config.channelProfile = .liveBroadcasting config.audioScenario = .gameStreaming config.areaCode = .global if config.appId?.count ?? 0 == 0 { - aui_error("config.appId is empty, please check 'AUIRoomContext.shared.commonConfig.appId'", tag: "AUIKaraokeRoomService") - assert(false, "config.appId is empty, please check 'AUIRoomContext.shared.commonConfig.appId'") + aui_error("config.appId is empty, please check 'AUIRoomContext.shared.appId'", tag: "AUIKaraokeRoomService") + assert(false, "config.appId is empty, please check 'AUIRoomContext.shared.appId'") } return config } @@ -153,7 +153,7 @@ extension TestServiceViewController { let commonConfig = AUICommonConfig() - commonConfig.appId = appid + AUIRoomContext.shared.appId = appid let rtcEngine = self._createRtcEngine(commonConfig: commonConfig) diff --git a/iOS/Example/Podfile.lock b/iOS/Example/Podfile.lock index a60d97dc..679148a5 100644 --- a/iOS/Example/Podfile.lock +++ b/iOS/Example/Podfile.lock @@ -4,9 +4,9 @@ PODS: - AgoraRtcEngine_Special_iOS (4.1.1.247) - AgoraRtm_iOS (2.1.4) - Alamofire (5.8.0) - - AUIKitCore (0.5.1): - - AUIKitCore/All (= 0.5.1) - - AUIKitCore/All (0.5.1): + - AUIKitCore (0.5.2): + - AUIKitCore/All (= 0.5.2) + - AUIKitCore/All (0.5.2): - Agora_Chat_iOS - AgoraLyricsScore - AgoraRtcEngine_Special_iOS (~> 4.1.1.1) @@ -62,7 +62,7 @@ SPEC CHECKSUMS: AgoraRtcEngine_Special_iOS: 1da915f9ea50947b0c01f3a7f9674df4e3c90820 AgoraRtm_iOS: 11b767ee81a7202dcf09e045cd2d359b5abbc965 Alamofire: 0e92e751b3e9e66d7982db43919d01f313b8eb91 - AUIKitCore: 442f2fdb7eb54df5751592d4c9b37fc2f4773fad + AUIKitCore: 388fb75a4cd26af9c46dac9b651457dd69e906a7 libpag: 8a5c6b406458d85db48b05145d5dba9c406f2097 MJRefresh: fdf5e979eb406a0341468932d1dfc8b7f9fce961 ScoreEffectUI: bf1195b4d41a73d43c236450b5d7f958989844aa