@tencent-rtc/mcp 1.6.4 → 1.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/knowledge/chunker.js +83 -54
  2. package/knowledge/path-meta.js +179 -26
  3. package/knowledge/search/exact-lookup.js +153 -0
  4. package/knowledge/search/filter-pool.js +73 -19
  5. package/knowledge/search/product-scope-intent.js +2 -2
  6. package/knowledge/search/requires-framework.js +2 -2
  7. package/knowledge/search/search-knowledge.js +235 -58
  8. package/package.json +1 -1
  9. package/resource/index/manifest.json +1 -1
  10. package/resource/integration/callkit/preset/android/integration.md +2 -4
  11. package/resource/integration/callkit/preset/flutter/integration.md +4 -5
  12. package/resource/integration/callkit/preset/ios/integration.md +1 -4
  13. package/resource/integration/callkit/preset/react/integration.md +13 -20
  14. package/resource/integration/callkit/preset/vue/integration.md +14 -21
  15. package/resource/integration/chat/preset/android/integration.md +6 -9
  16. package/resource/integration/chat/preset/flutter/integration.md +9 -12
  17. package/resource/integration/chat/preset/ios/integration.md +2 -4
  18. package/resource/integration/chat/preset/react/integration.md +0 -10
  19. package/resource/integration/livekit/preset/live/android/live-audience-integration.md +129 -0
  20. package/resource/integration/livekit/preset/live/android/live-host-integration.md +219 -0
  21. package/resource/integration/livekit/preset/live/android/live-list-integration.md +261 -0
  22. package/resource/integration/livekit/preset/live/android/prepare-integration.md +254 -0
  23. package/resource/integration/livekit/preset/live/ios/live-audience-integration.md +202 -0
  24. package/resource/integration/livekit/preset/live/ios/live-host-integration.md +369 -0
  25. package/resource/integration/livekit/preset/live/ios/live-list-integration.md +229 -0
  26. package/resource/integration/livekit/preset/live/ios/prepare-integration.md +204 -0
  27. package/resource/integration/livekit/preset/live/vue/live-list-integration.md +0 -3
  28. package/resource/integration/livekit/preset/live/vue/live-player-desk-integration.md +0 -5
  29. package/resource/integration/livekit/preset/live/vue/live-player-h5-integration.md +0 -6
  30. package/resource/integration/livekit/preset/live/vue/live-pusher-integration.md +5 -10
  31. package/resource/integration/roomkit/preset/vue/integration.md +0 -4
  32. package/resource/knowledge/callkit/best-practice/web/callengine-invitation.md +80 -0
  33. package/resource/knowledge/callkit/best-practice/web/callengine-log-control.md +24 -0
  34. package/resource/knowledge/callkit/best-practice/web/callkit-call-vs-calls.md +116 -0
  35. package/resource/knowledge/callkit/core-sdk/android/answer-call.md +7 -8
  36. package/resource/knowledge/callkit/core-sdk/android/make-call.md +5 -7
  37. package/resource/knowledge/callkit/core-sdk/android/offline-push.md +3 -5
  38. package/resource/knowledge/callkit/core-sdk/flutter/answer-call.md +2 -6
  39. package/resource/knowledge/callkit/core-sdk/flutter/make-call.md +2 -6
  40. package/resource/knowledge/callkit/core-sdk/flutter/offline-push.md +4 -9
  41. package/resource/knowledge/callkit/core-sdk/ios/answer-call.md +1 -4
  42. package/resource/knowledge/callkit/core-sdk/ios/make-call.md +8 -11
  43. package/resource/knowledge/callkit/core-sdk/ios/offline-push.md +17 -23
  44. package/resource/knowledge/callkit/core-sdk/web/call-engine.md +33 -0
  45. package/resource/knowledge/callkit/core-sdk/web/call-event.md +327 -0
  46. package/resource/knowledge/callkit/core-sdk/web/callengine-api-overview.md +33 -0
  47. package/resource/knowledge/callkit/faq/android.md +0 -2
  48. package/resource/knowledge/callkit/faq/error-code.md +0 -2
  49. package/resource/knowledge/callkit/faq/flutter.md +2 -2
  50. package/resource/knowledge/callkit/faq/ios.md +3 -5
  51. package/resource/knowledge/callkit/faq/web.md +2 -3
  52. package/resource/knowledge/callkit/preset/android/api.md +2 -5
  53. package/resource/knowledge/callkit/preset/ios/api.md +0 -2
  54. package/resource/knowledge/callkit/preset/react/api.md +445 -0
  55. package/resource/knowledge/callkit/preset/react/uikit-api-reference.md +445 -0
  56. package/resource/knowledge/callkit/preset/vue/api.md +465 -0
  57. package/resource/knowledge/callkit/preset/vue/uikit-api-reference.md +465 -0
  58. package/resource/knowledge/chat/best-practice/web/image-message-url-handling.md +16 -0
  59. package/resource/knowledge/chat/preset/android/features/chat-setting.md +1 -1
  60. package/resource/knowledge/chat/preset/android/features/conversation-list.md +1 -1
  61. package/resource/knowledge/chat/preset/android/features/language.md +0 -1
  62. package/resource/knowledge/chat/preset/android/features/message-input.md +1 -1
  63. package/resource/knowledge/chat/preset/android/features/message-list.md +2 -3
  64. package/resource/knowledge/chat/preset/android/features/search.md +0 -1
  65. package/resource/knowledge/chat/preset/android/features/theme.md +1 -1
  66. package/resource/knowledge/chat/preset/android-view/integration.md +3 -11
  67. package/resource/knowledge/chat/preset/flutter/features/conversation-list.md +0 -1
  68. package/resource/knowledge/chat/preset/flutter/features/message-list.md +1 -2
  69. package/resource/knowledge/chat/preset/flutter/features/search.md +5 -6
  70. package/resource/knowledge/chat/preset/flutter/features/theme.md +2 -2
  71. package/resource/knowledge/chat/preset/ios/features/chat-setting.md +1 -1
  72. package/resource/knowledge/chat/preset/ios/features/conversation-list.md +1 -2
  73. package/resource/knowledge/chat/preset/ios/features/message-list.md +1 -2
  74. package/resource/knowledge/chat/preset/ios/features/search.md +0 -1
  75. package/resource/knowledge/chat/preset/ios-uikit/integration.md +13 -15
  76. package/resource/knowledge/chat/preset/react/features/conversation-list.md +5 -5
  77. package/resource/knowledge/chat/preset/react/features/message-input.md +2 -3
  78. package/resource/knowledge/chat/preset/react/features/search.md +0 -1
  79. package/resource/knowledge/chat/preset/react/features/theme.md +0 -1
  80. package/resource/knowledge/livekit/core-sdk/api-reference/android/AudioEffectStore.md +7 -14
  81. package/resource/knowledge/livekit/core-sdk/api-reference/android/BarrageStore.md +5 -8
  82. package/resource/knowledge/livekit/core-sdk/api-reference/android/BattleStore.md +15 -18
  83. package/resource/knowledge/livekit/core-sdk/api-reference/android/CameraView.md +1 -2
  84. package/resource/knowledge/livekit/core-sdk/api-reference/android/CoGuestStore.md +15 -20
  85. package/resource/knowledge/livekit/core-sdk/api-reference/android/CoHostStore.md +10 -13
  86. package/resource/knowledge/livekit/core-sdk/api-reference/android/DeviceStore.md +2 -4
  87. package/resource/knowledge/livekit/core-sdk/api-reference/android/GiftStore.md +4 -6
  88. package/resource/knowledge/livekit/core-sdk/api-reference/android/LikeStore.md +2 -4
  89. package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveAudienceStore.md +2 -4
  90. package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveCoreView.md +1 -2
  91. package/resource/knowledge/livekit/core-sdk/api-reference/android/LiveSeatStore.md +8 -10
  92. package/resource/knowledge/livekit/core-sdk/api-reference/android/LoginStore.md +5 -7
  93. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/AudioEffectStore.md +7 -14
  94. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BarrageStore.md +6 -9
  95. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BaseBeautyStore.md +1 -2
  96. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/BattleStore.md +15 -18
  97. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoGuestStore.md +15 -20
  98. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/CoHostStore.md +10 -13
  99. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/DeviceStore.md +2 -4
  100. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/GiftStore.md +4 -6
  101. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LikeStore.md +2 -4
  102. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveAudienceStore.md +2 -4
  103. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveCoreView.md +1 -2
  104. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LiveSeatStore.md +8 -10
  105. package/resource/knowledge/livekit/core-sdk/api-reference/flutter/LoginStore.md +3 -5
  106. package/resource/knowledge/livekit/core-sdk/api-reference/ios/AudioEffectStore.md +7 -14
  107. package/resource/knowledge/livekit/core-sdk/api-reference/ios/BarrageStore.md +5 -8
  108. package/resource/knowledge/livekit/core-sdk/api-reference/ios/BaseBeautyStore.md +1 -2
  109. package/resource/knowledge/livekit/core-sdk/api-reference/ios/BattleStore.md +6 -9
  110. package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoGuestStore.md +5 -10
  111. package/resource/knowledge/livekit/core-sdk/api-reference/ios/CoHostStore.md +3 -6
  112. package/resource/knowledge/livekit/core-sdk/api-reference/ios/DeviceStore.md +2 -4
  113. package/resource/knowledge/livekit/core-sdk/api-reference/ios/GiftStore.md +4 -6
  114. package/resource/knowledge/livekit/core-sdk/api-reference/ios/LikeStore.md +2 -4
  115. package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveAudienceStore.md +2 -4
  116. package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveCoreView.md +1 -2
  117. package/resource/knowledge/livekit/core-sdk/api-reference/ios/LiveSeatStore.md +4 -6
  118. package/resource/knowledge/livekit/core-sdk/api-reference/ios/LoginStore.md +3 -5
  119. package/resource/knowledge/livekit/core-sdk/api-reference/{web → vue}/index.md +24 -24
  120. package/resource/knowledge/livekit/core-sdk/{voice/android/voice-audio-effect.md → features/android/audio-effect.md} +1 -2
  121. package/resource/knowledge/livekit/core-sdk/{live/android/live-gift.md → features/android/gift.md} +2 -3
  122. package/resource/knowledge/livekit/core-sdk/{voice/android/voice-room-list.md → features/android/live-list.md} +2 -4
  123. package/resource/knowledge/livekit/core-sdk/{live/flutter/live-audio-effect.md → features/flutter/audio-effect.md} +0 -2
  124. package/resource/knowledge/livekit/core-sdk/{voice/flutter/voice-barrage.md → features/flutter/barrage.md} +2 -2
  125. package/resource/knowledge/livekit/core-sdk/{live/flutter/live-gift.md → features/flutter/gift.md} +2 -3
  126. package/resource/knowledge/livekit/core-sdk/{voice/flutter/voice-room-list.md → features/flutter/live-list.md} +1 -1
  127. package/resource/knowledge/livekit/core-sdk/{voice/ios/voice-audience-list.md → features/ios/audience-list.md} +1 -2
  128. package/resource/knowledge/livekit/core-sdk/{voice/ios/voice-audio-effect.md → features/ios/audio-effect.md} +1 -3
  129. package/resource/knowledge/livekit/core-sdk/{live/ios/live-base-beauty.md → features/ios/base-beauty.md} +2 -2
  130. package/resource/knowledge/livekit/core-sdk/{voice/ios/voice-gift.md → features/ios/gift.md} +2 -3
  131. package/resource/knowledge/livekit/core-sdk/{voice/ios/voice-room-list.md → features/ios/live-list.md} +2 -4
  132. package/resource/knowledge/livekit/core-sdk/live/android/{live-co-guest-interaction.md → co-guest-interaction.md} +0 -1
  133. package/resource/knowledge/livekit/core-sdk/live/android/{live-host-interaction.md → host-interaction.md} +5 -7
  134. package/resource/knowledge/livekit/core-sdk/live/android/{live-integration.md → integration.md} +3 -6
  135. package/resource/knowledge/livekit/core-sdk/live/flutter/{live-co-guest-interaction.md → co-guest-interaction.md} +1 -1
  136. package/resource/knowledge/livekit/core-sdk/live/flutter/{live-host-interaction.md → host-interaction.md} +0 -2
  137. package/resource/knowledge/livekit/core-sdk/live/flutter/{live-integration.md → integration.md} +1 -4
  138. package/resource/knowledge/livekit/core-sdk/live/ios/{live-co-guest-interaction.md → co-guest-interaction.md} +0 -1
  139. package/resource/knowledge/livekit/core-sdk/live/ios/{live-host-interaction.md → host-interaction.md} +2 -4
  140. package/resource/knowledge/livekit/core-sdk/live/ios/{live-integration.md → integration.md} +2 -5
  141. package/resource/knowledge/livekit/core-sdk/voice/android/{voice-host-interaction.md → host-interaction.md} +3 -5
  142. package/resource/knowledge/livekit/core-sdk/voice/android/{voice-integration.md → integration.md} +3 -6
  143. package/resource/knowledge/livekit/core-sdk/voice/flutter/{voice-co-guest-interaction.md → co-guest-interaction.md} +1 -2
  144. package/resource/knowledge/livekit/core-sdk/voice/flutter/{voice-integration.md → integration.md} +6 -9
  145. package/resource/knowledge/livekit/core-sdk/voice/ios/{voice-co-guest-interaction.md → co-guest-interaction.md} +2 -2
  146. package/resource/knowledge/livekit/core-sdk/voice/ios/{voice-host-interaction.md → host-interaction.md} +4 -6
  147. package/resource/knowledge/livekit/core-sdk/voice/ios/{voice-integration.md → integration.md} +1 -4
  148. package/resource/knowledge/livekit/preset/live/vue/features/barrage.md +0 -2
  149. package/resource/knowledge/push/api-reference/android.md +123 -0
  150. package/resource/knowledge/push/api-reference/flutter.md +176 -0
  151. package/resource/knowledge/push/api-reference/harmonyos.md +138 -0
  152. package/resource/knowledge/push/api-reference/ios.md +176 -0
  153. package/resource/knowledge/push/api-reference/react-native.md +147 -0
  154. package/resource/knowledge/push/api-reference/uni-app.md +147 -0
  155. package/resource/knowledge/push/api-reference/unity.md +119 -0
  156. package/resource/knowledge/push/api-reference/unreal-engine.md +123 -0
  157. package/resource/knowledge/push/config/android.md +4 -7
  158. package/resource/knowledge/push/config/harmonyos.md +0 -3
  159. package/resource/knowledge/push/config/ios.md +12 -20
  160. package/resource/knowledge/push/config/react-native.md +18 -26
  161. package/resource/knowledge/push/config/unity.md +20 -28
  162. package/resource/knowledge/push/config/unreal-engine.md +21 -29
  163. package/resource/knowledge/push/integration/android.md +6 -8
  164. package/resource/knowledge/push/integration/flutter.md +6 -9
  165. package/resource/knowledge/push/integration/harmonyos.md +1 -0
  166. package/resource/knowledge/push/integration/ios.md +7 -9
  167. package/resource/knowledge/push/integration/react-native.md +9 -13
  168. package/resource/knowledge/push/integration/uni-app.md +7 -7
  169. package/resource/knowledge/push/integration/unity.md +10 -13
  170. package/resource/knowledge/push/integration/unreal-engine.md +6 -9
  171. package/resource/knowledge/push/overview/prepare.md +2 -2
  172. package/resource/knowledge/roomkit/core-sdk/android/call-user-to-room.md +3 -3
  173. package/resource/knowledge/roomkit/core-sdk/android/capability-matrix.md +46 -0
  174. package/resource/knowledge/roomkit/core-sdk/android/room-participant-state.md +1 -1
  175. package/resource/knowledge/roomkit/core-sdk/android/room-state.md +2 -2
  176. package/resource/knowledge/roomkit/core-sdk/android/schedule-room.md +6 -6
  177. package/resource/knowledge/roomkit/core-sdk/android/unsupported-features.md +79 -0
  178. package/resource/knowledge/roomkit/core-sdk/flutter/capability-matrix.md +46 -0
  179. package/resource/knowledge/roomkit/core-sdk/flutter/room-participant-state.md +1 -1
  180. package/resource/knowledge/roomkit/core-sdk/flutter/unsupported-features.md +79 -0
  181. package/resource/knowledge/roomkit/core-sdk/ios/capability-matrix.md +46 -0
  182. package/resource/knowledge/roomkit/core-sdk/ios/room-participant-state.md +1 -1
  183. package/resource/knowledge/roomkit/core-sdk/ios/unsupported-features.md +79 -0
  184. package/resource/knowledge/roomkit/preset/android/integration.md +5 -7
  185. package/resource/knowledge/roomkit/preset/flutter/integration.md +2 -7
  186. package/resource/knowledge/roomkit/preset/ios/integration.md +3 -9
  187. package/resource/knowledge/roomkit/preset/react/integration.md +12 -16
  188. package/resource/knowledge/trtc/android/TRTCCloud.md +154 -238
  189. package/resource/knowledge/trtc/android/TRTCCloudDef.md +133 -134
  190. package/resource/knowledge/trtc/android/TRTCCloudListener.md +86 -120
  191. package/resource/knowledge/trtc/android/TRTCStatistics.md +10 -10
  192. package/resource/knowledge/trtc/android/TXAudioEffectManager.md +10 -30
  193. package/resource/knowledge/trtc/android/TXBeautyManager.md +25 -25
  194. package/resource/knowledge/trtc/android/TXDeviceManager.md +2 -2
  195. package/resource/knowledge/trtc/android/TXLiteAVCode.md +12 -12
  196. package/resource/knowledge/trtc/c++/ITRTCCloud.md +166 -261
  197. package/resource/knowledge/trtc/c++/ITRTCStatistics.md +12 -12
  198. package/resource/knowledge/trtc/c++/ITXAudioEffectManager.md +10 -30
  199. package/resource/knowledge/trtc/c++/ITXDeviceManager.md +9 -11
  200. package/resource/knowledge/trtc/c++/TRTCCloudCallback.md +96 -130
  201. package/resource/knowledge/trtc/c++/TRTCTypeDef.md +122 -123
  202. package/resource/knowledge/trtc/c++/TXLiteAVCode.md +12 -12
  203. package/resource/knowledge/trtc/ios/TRTCCloud.md +168 -255
  204. package/resource/knowledge/trtc/ios/TRTCCloudDef.md +124 -125
  205. package/resource/knowledge/trtc/ios/TRTCCloudDelegate.md +89 -124
  206. package/resource/knowledge/trtc/ios/TRTCStatistics.md +10 -10
  207. package/resource/knowledge/trtc/ios/TXAudioEffectManager.md +9 -28
  208. package/resource/knowledge/trtc/ios/TXBeautyManager.md +25 -25
  209. package/resource/knowledge/trtc/ios/TXDeviceManager.md +9 -11
  210. package/resource/knowledge/trtc/ios/TXLiteAVCode.md +12 -12
  211. package/server.js +21 -21
  212. package/tools/common/finalize_answer.js +1 -1
  213. package/tools/common/present_framework_choice.js +2 -2
  214. package/tools/common/search_trtc_knowledge.js +3 -3
  215. package/tools/common/submit_feedback.js +1 -1
  216. package/tools/definitions/get_native_live_uikit_integration_def.js +61 -0
  217. package/tools/definitions/get_native_livekit_core_integration_def.js +3 -3
  218. package/tools/definitions/present_framework_choice_def.js +2 -2
  219. package/tools/definitions/search_trtc_knowledge_def.js +5 -5
  220. package/tools/index.js +2 -0
  221. package/tools/live/get_native_live_uikit_integration.js +69 -0
  222. package/tools/live/get_native_livekit_core_integration.js +6 -6
  223. package/utils/report-cls-client.js +1 -1
  224. package/utils/report-es-client.js +1 -1
  225. package/resource/knowledge/callkit/preset/web/api.md +0 -83
  226. package/resource/knowledge/livekit/core-sdk/live/android/live-audio-effect.md +0 -226
  227. package/resource/knowledge/livekit/core-sdk/live/android/live-live-list.md +0 -438
  228. package/resource/knowledge/livekit/core-sdk/live/flutter/live-barrage.md +0 -490
  229. package/resource/knowledge/livekit/core-sdk/live/flutter/live-live-list.md +0 -726
  230. package/resource/knowledge/livekit/core-sdk/live/ios/live-audience-list.md +0 -264
  231. package/resource/knowledge/livekit/core-sdk/live/ios/live-audio-effect.md +0 -216
  232. package/resource/knowledge/livekit/core-sdk/live/ios/live-gift.md +0 -407
  233. package/resource/knowledge/livekit/core-sdk/live/ios/live-live-list.md +0 -349
  234. package/resource/knowledge/livekit/core-sdk/voice/android/voice-audience-list.md +0 -269
  235. package/resource/knowledge/livekit/core-sdk/voice/android/voice-barrage.md +0 -456
  236. package/resource/knowledge/livekit/core-sdk/voice/android/voice-gift.md +0 -455
  237. package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-audience-list.md +0 -260
  238. package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-audio-effect.md +0 -598
  239. package/resource/knowledge/livekit/core-sdk/voice/flutter/voice-gift.md +0 -424
  240. package/resource/knowledge/livekit/core-sdk/voice/ios/voice-barrage.md +0 -408
  241. /package/resource/knowledge/livekit/core-sdk/{live/android/live-audience-list.md → features/android/audience-list.md} +0 -0
  242. /package/resource/knowledge/livekit/core-sdk/{live/android/live-barrage.md → features/android/barrage.md} +0 -0
  243. /package/resource/knowledge/livekit/core-sdk/{live/android/live-base-beauty.md → features/android/base-beauty.md} +0 -0
  244. /package/resource/knowledge/livekit/core-sdk/{live/flutter/live-audience-list.md → features/flutter/audience-list.md} +0 -0
  245. /package/resource/knowledge/livekit/core-sdk/{live/flutter/live-base-beauty.md → features/flutter/base-beauty.md} +0 -0
  246. /package/resource/knowledge/livekit/core-sdk/{live/ios/live-barrage.md → features/ios/barrage.md} +0 -0
  247. /package/resource/knowledge/livekit/core-sdk/voice/android/{voice-co-guest-interaction.md → co-guest-interaction.md} +0 -0
@@ -1,349 +0,0 @@
1
- `LiveListStore` is the core module of **AtomicXCore** responsible for managing the live room list, creating and joining rooms, and maintaining room state. With `LiveListStore`, you can implement comprehensive live streaming lifecycle management in your application.
2
-
3
- ## Core Features
4
- - **Live Room List Fetching**: Retrieve all currently public live rooms, returned one page at a time.
5
-
6
- - **Live Lifecycle Management**: Provides a complete set of interfaces for the entire live streaming workflow, including room creation, going live, joining, leaving, and ending a live session.
7
-
8
- - **Real-Time Event Listening**: Listen for key events such as live session end or users being removed from a room.
9
-
10
- ## Core Concepts
11
- | <strong>Core Concept</strong> | <strong>Type</strong> | <strong>Core Responsibility & Description</strong> |
12
- | --- | --- | --- |
13
- | <code>LiveInfo</code> | <code>struct</code> | - Represents the complete information model of a live room.<br>- Includes the live room ID (<code>liveID</code>), name (<code>liveName</code>), owner information (<code>liveOwner</code>), and custom metadata (<code>metaData</code>), among other properties. |
14
- | <code>LiveListState</code> | <code>struct</code> | - Represents the current state of the live list module.<br>- The core property <code>liveList</code> is a StateFlow containing the fetched live room list;<br>- <code>currentLive</code> represents the information of the live room the user is currently in. |
15
- | <code>LiveListEvent</code> | <code>enum</code> | Handles global live room events, including <code>.onLiveEnded</code> (live ended) and <code>.onKickedOutOfLive</code> (user removed from live), for responding to key room state changes. |
16
- | <code>LiveListStore</code> | <code>class</code> | - The core management class for interacting with the live room list and room lifecycle.<br>- It is a global singleton responsible for all operations such as creating, joining, and updating live room information. |
17
-
18
- ## Implementation
19
-
20
- ### Step 1: Component Integration
21
- - **Video Live Streaming**:Refer to Quick Start to integrate AtomicXCore and complete the implementation of the Host Video Streaming and Audience Join and Watch features.
22
-
23
- - **Voice Chat Room**:Refer to Quick Start to integrate AtomicXCore and complete the implementation of the Host Audio Streaming and Audience Join and Watch features.
24
-
25
- ### Step 2: Implement Audience Entry from Live Room List
26
-
27
- Create a page to display the live room list using `UICollectionView` to lay out live room cards. When a user taps a card, retrieve the `liveID` for that room and navigate to the audience viewing page.
28
- ``` swift
29
- import AtomicXCore
30
- import SnapKit
31
- import RTCRoomEngine
32
- import Combine
33
-
34
- class LiveListViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
35
-
36
- private let liveListStore = LiveListStore.shared
37
- private var cancellables = Set<AnyCancellable>()
38
- private var liveList: [LiveInfo] = []
39
- private var collectionView: UICollectionView!
40
-
41
- override func viewDidLoad() {
42
- super.viewDidLoad()
43
- setupUI()
44
- bindStore()
45
- fetchLiveList()
46
- }
47
-
48
- private func bindStore() {
49
- // Subscribe to state to automatically receive list updates
50
- liveListStore.state
51
- .subscribe(StatePublisherSelector(keyPath: \LiveListState.liveList))
52
- .receive(on: DispatchQueue.main)
53
- .sink { [weak self] fetchedList in
54
- self?.liveList = fetchedList
55
- self?.collectionView.reloadData()
56
- }
57
- .store(in: &cancellables)
58
- }
59
-
60
- private func fetchLiveList() {
61
- liveListStore.fetchLiveList(cursor: "", count: 20) { result in
62
- if case .failure(let error) = result {
63
- print("Failed to fetch live room list: \(error.localizedDescription)")
64
- }
65
- }
66
- }
67
-
68
- // Called when the user taps a cell in the list
69
- func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
70
- let selectedLiveInfo = liveList[indexPath.item]
71
- // Create the audience viewing page and pass in the liveID
72
- let audienceVC = YourAudienceViewController(liveId: selectedLiveInfo.liveID)
73
- audienceVC.modalPresentationStyle = .fullScreen
74
- present(audienceVC, animated: true)
75
- }
76
-
77
- // --- UICollectionViewDataSource, Delegate, and UI setup methods ---
78
- private func setupUI() {
79
- let layout = UICollectionViewFlowLayout()
80
- // ... (Customize your layout as needed)
81
- collectionView = UICollectionView(frame: view.bounds, collectionViewLayout: layout)
82
- collectionView.dataSource = self
83
- collectionView.delegate = self
84
- collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: "LiveCell")
85
- view.addSubview(collectionView)
86
- }
87
-
88
- func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
89
- return liveList.count
90
- }
91
-
92
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
93
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "LiveCell", for: indexPath)
94
- cell.backgroundColor = .lightGray // Customize your cell style
95
- // let liveInfo = liveList[indexPath.item]
96
- // ... (e.g.: cell.titleLabel.text = liveInfo.liveName)
97
- return cell
98
- }
99
-
100
- func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
101
- // Adjust cell size for single or double column layout as needed
102
- let width = (view.bounds.width - 30) / 2
103
- return CGSize(width: width, height: width * 1.2)
104
- }
105
- }
106
- ```
107
-
108
- #### LiveInfo Parameter Reference
109
-
110
- |**Parameter Name**|**Type**|**Description**|
111
- |---------|---------|---------|
112
- |`liveID`|`String`|Unique identifier for the live room|
113
- |`liveName`|`String`|Title of the live room|
114
- |`coverURL`|`String`|URL of the live room cover image|
115
- |`liveOwner`|[LiveUserInfo](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveuserinfo)|Personal information of the room owner|
116
- |`totalViewerCount`|`Int`|Total number of viewers in the live room|
117
- |`categoryList`|`[NSNumber]`|List of category tags for the live room|
118
- |`notice`|`String`|Announcement information for the live room|
119
- |`metaData`|`[String: String]`|Developer-defined metadata for implementing complex business scenarios|
120
-
121
- ## Advanced Features
122
-
123
- ### Scenario 1: Category Filtering for Live Room List
124
-
125
- On the live plaza page, users can select category tags such as "Hot", "Music", "Games", etc. When a tag is selected, the live room list dynamically filters to display only rooms in the chosen category, helping users quickly discover relevant content.
126
-
127
- #### Implementation
128
-
129
- Use the `categoryList` property in the `LiveInfo` model. When the host sets a category at the start of the stream, the `LiveInfo` object returned by `fetchLiveList` includes this category data. After fetching the full live room list, filter it on the client side based on the selected category and update the UI.
130
-
131
- #### Code Example
132
-
133
- The following example shows how to extend a `LiveListManager` in `LiveListViewController` to handle data fetching and category filtering:
134
- ``` swift
135
- import AtomicXCore
136
- import Combine
137
-
138
- // 1. Data manager for fetching and filtering
139
- class LiveListManager {
140
- private let liveListStore = LiveListStore.shared
141
- private var cancellables = Set<AnyCancellable>()
142
- private var fullLiveList: [LiveInfo] = []
143
-
144
- // Publisher for the filtered live list
145
- let filteredLiveListPublisher = CurrentValueSubject<[LiveInfo], Never>([])
146
-
147
- init() {
148
- liveListStore.state
149
- .subscribe(StatePublisherSelector(keyPath: \LiveListState.liveList))
150
- .receive(on: DispatchQueue.main)
151
- .sink { [weak self] fetchedList in
152
- self?.fullLiveList = fetchedList
153
- // By default, publish the complete list
154
- self?.filteredLiveListPublisher.send(fetchedList)
155
- }
156
- .store(in: &cancellables)
157
- }
158
-
159
- func fetchFirstPage() {
160
- liveListStore.fetchLiveList(cursor: "", count: 20) { _ in }
161
- }
162
-
163
- /// Filter the live list by category
164
- func filterLiveList(by categoryId: NSNumber?) {
165
- guard let categoryId = categoryId else {
166
- // Show the full list if no category is selected
167
- filteredLiveListPublisher.send(fullLiveList)
168
- return
169
- }
170
- let filteredList = fullLiveList.filter { liveInfo in
171
- liveInfo.categoryList.contains(categoryId)
172
- }
173
- filteredLiveListPublisher.send(filteredList)
174
- }
175
- }
176
-
177
- // 2. Use the manager in your LiveListViewController
178
- class LiveListViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
179
-
180
- private let manager = LiveListManager()
181
- private var cancellables = Set<AnyCancellable>()
182
- private var liveList: [LiveInfo] = []
183
- private var collectionView: UICollectionView!
184
-
185
- override func viewDidLoad() {
186
- super.viewDidLoad()
187
- // ... setupUI ...
188
-
189
- // Bind data
190
- manager.filteredLiveListPublisher
191
- .receive(on: DispatchQueue.main)
192
- .sink { [weak self] filteredList in
193
- self?.liveList = filteredList
194
- self?.collectionView.reloadData()
195
- }
196
- .store(in: &cancellables)
197
-
198
- // Fetch the first page
199
- manager.fetchFirstPage()
200
- }
201
-
202
- // Handle category selection (e.g., UISegmentedControl)
203
- @objc func categorySegmentDidChange(_ sender: UISegmentedControl) {
204
- let selectedCategoryId: NSNumber? = 1 // Example: "Music" category ID is 1
205
- manager.filterLiveList(by: selectedCategoryId)
206
- }
207
-
208
- // ... (UICollectionView related code)
209
- }
210
- ```
211
-
212
- ### Scenario 2: Swipe-to-Play for Live Room List
213
-
214
- Users can switch between live rooms by swiping up or down. When a new live room is centered on the screen, its video will automatically start preview playback; when it is swiped away or no longer visible on the screen, playback will automatically stop to save bandwidth and device resources.
215
-
216
- > **Note:**
217
- >
218
-
219
- > **Swipe-to-Play **is currently only supported for Video Live Streaming.
220
- >
221
-
222
- #### Interaction Flow
223
-
224
- #### Implementation
225
-
226
- `LiveCoreView` supports multiple instances. Create a separate `LiveCoreView` for each `UICollectionViewCell`. By listening to the scroll delegate methods of `UICollectionView`, you can control when the `LiveCoreView` in each cell should start or stop streaming, enabling "play on swipe in, stop on swipe out".
227
-
228
- #### Code Example
229
-
230
- Create a custom `LiveFeedCell` containing a `LiveCoreView`. Then, manage playback state in your view controller:
231
- ``` swift
232
- import UIKit
233
- import AtomicXCore
234
-
235
- // 1. Custom UICollectionViewCell with LiveCoreView
236
- class LiveFeedCell: UICollectionViewCell {
237
- private var liveCoreView: LiveCoreView?
238
-
239
- func setLiveInfo(_ liveInfo: LiveInfo) {
240
- // Create a new LiveCoreView for the new live info
241
- liveCoreView = LiveCoreView(viewType: .playView)
242
- guard let liveCoreView = liveCoreView else { return }
243
- contentView.addSubview(liveCoreView)
244
- liveCoreView.frame = contentView.bounds
245
- }
246
-
247
- func startPlay(roomId: String) {
248
- liveCoreView?.startPreviewLiveStream(roomId: roomId, isMuteAudio: false)
249
- }
250
-
251
- func stopPlay(roomId: String) {
252
- liveCoreView?.stopPreviewLiveStream(roomId: roomId)
253
- }
254
- }
255
-
256
- // 2. Manage playback in the ViewController
257
- class LiveFeedViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
258
-
259
- private var collectionView: UICollectionView!
260
- private var liveList: [LiveInfo] = []
261
- private var currentPlayingIndexPath: IndexPath?
262
-
263
- // Called when scrolling stops
264
- func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
265
- let page = Int(scrollView.contentOffset.y / view.frame.height)
266
- let indexPath = IndexPath(item: page, section: 0)
267
- // Switch playback only when the centered cell changes
268
- if currentPlayingIndexPath != indexPath {
269
- playVideo(at: indexPath)
270
- }
271
- }
272
-
273
- // Called when a cell is about to leave the screen
274
- func collectionView(_ collectionView: UICollectionView, didEndDisplaying cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
275
- if let liveCell = cell as? LiveFeedCell {
276
- let liveInfo = liveList[indexPath.item]
277
- liveCell.stopPlay(roomId: liveInfo.liveID)
278
- }
279
- }
280
-
281
- private func playVideo(at indexPath: IndexPath) {
282
- if let cell = collectionView.cellForItem(at: indexPath) as? LiveFeedCell {
283
- let liveInfo = liveList[indexPath.item]
284
- cell.startPlay(roomId: liveInfo.liveID)
285
- currentPlayingIndexPath = indexPath
286
- }
287
- }
288
-
289
- // ... (Other UICollectionViewDataSource methods)
290
- func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
291
- let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "LiveFeedCell", for: indexPath) as! LiveFeedCell
292
- cell.setLiveInfo(liveList[indexPath.item])
293
- return cell
294
- }
295
- }
296
- ```
297
-
298
- ## **API Documentation**
299
-
300
- For detailed information on all public interfaces, properties, and methods of [LiveListStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveliststore) and related classes, refer to the official API documentation included with the [AtomicXCore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore) framework. The relevant Stores used in this document are as follows:
301
- | <strong>Store/Component</strong> | <strong>Feature Description</strong> | <strong>API Documentation</strong> |
302
- | --- | --- | --- |
303
- | LiveCoreView | - Core view component for live video stream display and interaction.<br>- Responsible for video stream rendering and view widget handling, supporting scenarios such as host streaming, audience co-hosting, and host linking. | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/livecoreview">API Documentation</a> |
304
- | LiveListStore | Full lifecycle management of live rooms: create, join, leave, destroy rooms; query room list; modify live information (name, announcement, etc.); listen to live status (such as being removed or ended). | <a href="https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveliststore">API Documentation</a> |
305
-
306
- ## FAQs
307
-
308
- ### Is the list data for voice chat rooms and video live rooms the same?
309
-
310
- Yes. The data is unified; you do not need to fetch them separately. `LiveListStore` is a global singleton that manages the lifecycle of all "live" rooms in your application, including both video live rooms and voice chat rooms.
311
-
312
- ### How do I distinguish between voice chat rooms and video live rooms in the live room list?
313
-
314
- `LiveListStore` does not differentiate between room business types. You must filter and categorize the list after fetching, at the application or UI layer.
315
-
316
- We recommend two approaches:
317
-
318
- **Approach 1 (Recommended): Use seatLayoutTemplateID for differentiation.**
319
-
320
- This template ID defines the room layout. For supported template IDs and effects, refer to Run And Test.
321
- - **Step 1: Specify ID when creating a room**
322
-
323
- - When calling `LiveListStore.shared.createLive`, set the `seatLayoutTemplateID` property of `LiveInfo` based on your business scenario:
324
-
325
- - Voice chat rooms: Use template IDs in the range 1–199.
326
-
327
- - Video live rooms: Use template IDs in the range 200–999.
328
-
329
- - **Step 2: Filter when fetching the list**
330
-
331
- - On the client side, after receiving the list in `LiveListStore.state.liveList`, determine the business scenario by checking the template ID range.
332
-
333
- > **Note:**
334
- >
335
-
336
- > If the seatLayoutTemplateID does not match your business scenario (voice chat room or video live room), seat layout features may not work as expected.
337
- >
338
-
339
- **Approach 2:****Add a business prefix to **`liveID`**.**
340
-
341
- This is an optional, application-layer convention to help you filter rooms quickly.
342
-
343
- - **Step 1: Add prefix when creating a room**
344
-
345
- - When generating liveID and calling createLive, assign different prefixes for each business type. For example: video live room IDs start with "Live_" (e.g., Live_12345), voice chat room IDs start with "voice_" (e.g., voice_67890).
346
-
347
- - **Step 2: Check prefix when fetching the list**
348
-
349
- - On the client side, after fetching the list, distinguish rooms by checking the liveID prefix.
@@ -1,269 +0,0 @@
1
- `LiveAudienceStore` is a module in `AtomicXCore` designed for managing audience information in live streaming rooms. With `LiveAudienceStore`, you can implement a comprehensive audience list and management system for your live streaming application.
2
-
3
- ## Core Features
4
- - **Real-Time Audience List**: Retrieve and display all audience information currently present in the live room.
5
-
6
- - **Audience Count Statistics**: Access the accurate, real-time total number of viewers in the live room.
7
-
8
- - **Audience Activity Monitoring**: Subscribe to events to instantly detect when viewers join or leave.
9
-
10
- - **Administrator Privileges**: The host can promote regular viewers to administrators or revoke their admin status.
11
-
12
- - **Room Management**: The host or administrator can remove (kick out) any regular viewer from the live room.
13
-
14
- ## Core Concepts
15
-
16
- |**Core Concept**|**Type**|**Core Responsibilities & Description**|
17
- |---------|---------|---------|
18
- |`LiveUserInfo`|data class|Represents the basic information model of an audience member (user). It contains the user's unique identifier (`userID`), nickname (`userName`), and avatar URL (`avatarURL`).|
19
- |`LiveAudienceState`|data class|Represents the current state of the audience module. Its core property `audienceList` is a StateFlow that stores the real-time state of the audience list; `audienceCount` represents the real-time state of the current total number of viewers.|
20
- |`LiveAudienceListener`|abstract class|Represents real-time audience activity events. It includes `onAudienceJoined` (audience joins) and `onAudienceLeft` (audience leaves), used for incremental updates to the audience list.|
21
- |`LiveAudienceStore`|abstract class|This is the core management class for interacting with audience list functionality. Through it, you can obtain audience list snapshots, perform management operations, and subscribe to its `LiveAudienceListener` for real-time updates.|
22
-
23
- ## Implementation Guide
24
-
25
- ### Step 1: Component Integration
26
- - **Video Live Streaming**: Please refer to Quick Start to integrate AtomicXCore
27
-
28
- - **Voice Chat Room**: Please refer to Quick Start to integrate AtomicXCore.
29
-
30
- ### Step 2: Initialize and Retrieve the Audience List
31
-
32
- Obtain a `LiveAudienceStore` instance bound to the current live room's `liveId`, and fetch the current audience list for the initial display.
33
- ``` kotlin
34
- import kotlinx.coroutines.*
35
- import kotlinx.coroutines.flow.*
36
- import io.trtc.tuikit.atomicxcore.api.CompletionHandler
37
- import io.trtc.tuikit.atomicxcore.api.live.LiveAudienceStore
38
- import io.trtc.tuikit.atomicxcore.api.live.LiveUserInfo
39
-
40
- class AudienceManager(
41
- private val liveId: String
42
- ) {
43
- private val audienceStore: LiveAudienceStore = LiveAudienceStore.create(liveId)
44
- private val scope = CoroutineScope(Dispatchers.Main)
45
-
46
- // Expose the [full] audience list state flow for UI layer subscription
47
- private val _audienceList = MutableStateFlow<List<LiveUserInfo>>(emptyList())
48
- val audienceList: StateFlow<List<LiveUserInfo>> = _audienceList.asStateFlow()
49
-
50
- // Expose the audience count state flow
51
- private val _audienceCount = MutableStateFlow(0)
52
- val audienceCount: StateFlow<Int> = _audienceCount.asStateFlow()
53
-
54
- init {
55
- // 1. Subscribe to state and events, see next section for implementation
56
- subscribeToAudienceState()
57
- subscribeToAudienceEvents()
58
-
59
- // 2. Actively fetch initial data for the first screen
60
- fetchInitialAudienceList()
61
- }
62
-
63
- /// Actively fetch a snapshot of the audience list once
64
- private fun fetchInitialAudienceList() {
65
- audienceStore.fetchAudienceList(object : CompletionHandler {
66
- override fun onSuccess() {
67
- println("Successfully fetched the initial audience list")
68
- // After success, the data will be automatically updated via the state subscription channel below
69
- }
70
-
71
- override fun onFailure(code: Int, desc: String) {
72
- println("Failed to fetch the initial audience list: $desc")
73
- }
74
- })
75
- }
76
-
77
- // ... subsequent code
78
- }
79
- ```
80
-
81
- ### Step 3: Listen to Audience List State and Real-Time Activity
82
-
83
- Subscribe to the `liveAudienceState` of `audienceStore` and add a `LiveAudienceListener` to receive full list snapshots and real-time audience join/leave events. Use these updates to drive UI changes.
84
- ``` kotlin
85
- class AudienceManager {
86
- /// Subscribe to state for audience count and list snapshots
87
- private fun subscribeToAudienceState() {
88
- scope.launch {
89
- // audienceList is a full snapshot
90
- audienceStore.liveAudienceState.audienceList.collect { audienceList ->
91
- _audienceList.value = audienceList
92
- }
93
- }
94
-
95
- scope.launch {
96
- // audienceCount is the real-time total
97
- audienceStore.liveAudienceState.audienceCount.collect { count ->
98
- _audienceCount.value = count
99
- }
100
- }
101
- }
102
-
103
- private val liveAudienceListener = object : LiveAudienceListener() {
104
- override fun onAudienceJoined(newAudience: LiveUserInfo) {
105
- println("Audience ${newAudience.userName} joined the live room")
106
- // Incremental update: add the new audience member to the end of the current list
107
- val currentList = _audienceList.value.toMutableList()
108
- if (!currentList.any { it.userID == newAudience.userID }) {
109
- currentList.add(newAudience)
110
- _audienceList.value = currentList
111
- }
112
- }
113
-
114
- override fun onAudienceLeft(departedAudience: LiveUserInfo) {
115
- println("Audience ${departedAudience.userName} left the live room")
116
- // Incremental update: remove the departed audience member from the current list
117
- val currentList = _audienceList.value.toMutableList()
118
- currentList.removeAll { it.userID == departedAudience.userID }
119
- _audienceList.value = currentList
120
- }
121
- }
122
-
123
- /// Subscribe to events to handle real-time audience join/leave
124
- private fun subscribeToAudienceEvents() {
125
- audienceStore.addLiveAudienceListener(liveAudienceListener)
126
- }
127
- }
128
- ```
129
-
130
- ### Step 4: Manage Audience (Kick and Set Administrator)
131
-
132
- As a host or administrator, you can manage viewers in the live room.
133
-
134
- #### 4.1 Kick a Viewer Out of the Live Room
135
-
136
- Call the `kickUserOutOfRoom` method to remove a specified user from the live room.
137
- ``` kotlin
138
- class AudienceManager {
139
- fun kick(userId: String) {
140
- audienceStore.kickUserOutOfRoom(userId, object : CompletionHandler {
141
- override fun onSuccess() {
142
- println("Successfully kicked user $userId out of the room")
143
- // After a successful kick, you will receive an onAudienceLeft event
144
- }
145
-
146
- override fun onFailure(code: Int, desc: String) {
147
- println("Failed to kick user $userId: $desc")
148
- }
149
- })
150
- }
151
- }
152
- ```
153
-
154
- #### 4.2 Set or Revoke Administrator Status
155
-
156
- Use the `setAdministrator` and `revokeAdministrator` methods to manage a user's administrator status.
157
- ``` kotlin
158
- class AudienceManager {
159
- /// Promote user to administrator
160
- fun promoteToAdmin(userId: String) {
161
- audienceStore.setAdministrator(userId, object : CompletionHandler {
162
- override fun onSuccess() {
163
- println("Successfully promoted user $userId to administrator")
164
- }
165
-
166
- override fun onFailure(code: Int, desc: String) {
167
- println("Failed to set administrator: $desc")
168
- }
169
- })
170
- }
171
-
172
- /// Revoke user's administrator status
173
- fun revokeAdmin(userId: String) {
174
- audienceStore.revokeAdministrator(userId, object : CompletionHandler {
175
- override fun onSuccess() {
176
- println("Successfully revoked administrator status for user $userId")
177
- }
178
-
179
- override fun onFailure(code: Int, desc: String) {
180
- println("Failed to revoke administrator: $desc")
181
- }
182
- })
183
- }
184
- }
185
- ```
186
-
187
- ## Advanced Features
188
-
189
- ### Display a Welcome Message in the Barrage Area When a Viewer Joins
190
-
191
- When a new viewer enters the live room, a welcome message such as `"Welcome [user nickname] to the live room"` is automatically displayed locally in the barrage/chat area.
192
-
193
- #### Implementation
194
-
195
- Add a listener for the audience join event `LiveAudienceListener.onAudienceJoined` in `LiveAudienceStore` to receive real-time notifications when a new viewer joins. When triggered, extract the new viewer's nickname and call the `appendLocalTip` method of BarrageStore to insert the message locally.
196
- ``` kotlin
197
- import io.trtc.tuikit.atomicxcore.api.live.LiveAudienceListener
198
- import io.trtc.tuikit.atomicxcore.api.live.LiveAudienceStore
199
- import io.trtc.tuikit.atomicxcore.api.live.LiveUserInfo
200
- import io.trtc.tuikit.atomicxcore.api.barrage.Barrage
201
- import io.trtc.tuikit.atomicxcore.api.barrage.BarrageStore
202
- import io.trtc.tuikit.atomicxcore.api.barrage.BarrageType
203
-
204
- class LiveRoomManager(
205
- private val liveId: String
206
- ) {
207
-
208
- init {
209
- // Initialize two core managers
210
- setupWelcomeMessageFlow()
211
- }
212
-
213
- private val liveAudienceListener = object : LiveAudienceListener() {
214
- override fun onAudienceJoined(audience: LiveUserInfo) {
215
- // 3. Create a local tip message
216
- val welcomeTip = Barrage().apply {
217
- liveID = liveId
218
- messageType = BarrageType.TEXT
219
- textContent = "Welcome ${audience.userName} to the live room."
220
- }
221
-
222
- // 4. Get an instance of BarrageStore (this will be the same instance due to internal mechanisms)
223
- val barrageStore = BarrageStore.create(liveId)
224
-
225
- // 5. Use BarrageStore's method to insert it into the barrage list
226
- barrageStore.appendLocalTip(welcomeTip)
227
- }
228
- }
229
-
230
- private fun setupWelcomeMessageFlow() {
231
- // 1. Get an instance of LiveAudienceStore
232
- val audienceStore = LiveAudienceStore.create(liveId)
233
-
234
- // 2. Subscribe to audience events
235
- audienceStore.addLiveAudienceListener(liveAudienceListener)
236
- }
237
- }
238
- ```
239
-
240
- ## API Documentation
241
-
242
- For detailed information on all public interfaces, properties, and methods of [LiveAudienceStore](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.live/-live-audience-store/index.html) and its related classes, refer to the official API documentation included with the [AtomicX Core](https://tencent-rtc.github.io/TUIKit_Android/index.html) framework. The relevant Stores used in this document are as follows:
243
-
244
- |**Store/Component**|**Feature Description**|**API Documentation**|
245
- |---------|---------|---------|
246
- |LiveCoreView|Core view component for live video stream display and interaction: responsible for video stream rendering and view widget handling, supporting scenarios such as host streaming, audience co-hosting, and host-to-host connection.|[API Documentation](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.view/-live-core-view/index.html)|
247
- |LiveAudienceStore|Audience management: obtain real-time audience list (ID / name / avatar), count audience numbers, and listen for audience join/leave events.|[API Documentation](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.view/-live-core-view/index.html)|
248
- |BarrageStore|Barrage feature: send text/custom barrage, maintain barrage list, and listen to barrage status in real time.|[API Documentation](https://tencent-rtc.github.io/TUIKit_Android/-atomic-x%20-core%20-a-p-i/io.trtc.tuikit.atomicxcore.api.barrage/-barrage-store/index.html)|
249
-
250
- ## FAQs
251
-
252
- ### How is the online audience count (audienceCount) in LiveAudienceState updated? What are the timing and frequency?
253
-
254
- The update of `audienceCount` is not always strictly real-time. The mechanism is as follows:
255
- - **Active Join/Leave**: When a user actively joins or leaves the live room, the audience count change notification is triggered instantly. You will quickly observe the change in `audienceCount` in `LiveAudienceState`.
256
-
257
- - **Unexpected Disconnection**: If a user disconnects unexpectedly due to network issues, app crashes, and so on, the system determines their actual status using a heartbeat mechanism. Only when the user has no heartbeat for 90 consecutive seconds does the system consider them offline and trigger a count change notification.
258
-
259
- - **Update Mechanism and Frequency Control:**
260
-
261
- - Whether triggered instantly or with a delay, all audience count change notifications are broadcast as messages within the room.
262
-
263
- - There is an upper limit to the total number of messages per second in a room, with a per-room message rate limit of 40 messages per second.
264
-
265
- - Key Point: In scenarios with extremely high message traffic, such as "barrage storms" or rapid-fire gifting, if the message rate in the room exceeds the 40 messages/second threshold, to ensure the delivery of core messages (such as barrage), audience count change messages may be dropped by the rate-limiting policy.
266
-
267
- - **What does this mean for developers?**
268
-
269
- `audienceCount` is a near real-time, high-precision estimate, but in extreme high-concurrency scenarios, there may be brief delays or data loss. We recommend using it for UI display only, and not as the sole basis for billing, statistics, or other scenarios requiring absolute accuracy.