@tencent-rtc/mcp 1.3.8 → 1.3.9

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 (54) hide show
  1. package/package.json +1 -1
  2. package/resource/doc/chatuikit/android/integration.md +499 -203
  3. package/resource/doc/chatuikit/android/workflow.md +713 -0
  4. package/resource/doc/chatuikit/flutter/integration.md +1 -1
  5. package/resource/doc/livekit/voice/android/voice-audience-list.md +334 -0
  6. package/resource/doc/livekit/voice/android/voice-audio-effect.md +380 -0
  7. package/resource/doc/livekit/voice/android/voice-barrage.md +565 -0
  8. package/resource/doc/livekit/voice/android/voice-co-guest-interaction.md +745 -0
  9. package/resource/doc/livekit/voice/android/voice-gift.md +822 -0
  10. package/resource/doc/livekit/voice/android/voice-host-interaction.md +703 -0
  11. package/resource/doc/livekit/voice/android/voice-integration.md +940 -0
  12. package/resource/doc/livekit/voice/android/voice-room-list.md +575 -0
  13. package/resource/doc/livekit/voice/flutter/voice-co-guest-interaction.md +675 -0
  14. package/resource/doc/livekit/voice/flutter/voice-integration.md +936 -0
  15. package/resource/doc/livekit/voice/ios/voice-audience-list.md +339 -0
  16. package/resource/doc/livekit/voice/ios/voice-audio-effect.md +370 -0
  17. package/resource/doc/livekit/voice/ios/voice-barrage.md +517 -0
  18. package/resource/doc/livekit/voice/ios/voice-co-guest-interaction.md +708 -0
  19. package/resource/doc/livekit/voice/ios/voice-gift.md +783 -0
  20. package/resource/doc/livekit/voice/ios/voice-host-interaction.md +770 -0
  21. package/resource/doc/livekit/voice/ios/voice-integration.md +898 -0
  22. package/resource/doc/livekit/voice/ios/voice-room-list.md +485 -0
  23. package/resource/doc/roomkit/vue/integration.md +179 -288
  24. package/resource/doc/roomkit/vue/workflow.md +499 -253
  25. package/resource/doc/tuicallkit/android/integration.md +539 -83
  26. package/resource/doc/tuicallkit/android/workflow.md +441 -0
  27. package/tools/common/present-scenario-choice.js +16 -0
  28. package/tools/common/present-scenario-choice.js.map +1 -0
  29. package/tools/definitions/get_native_call_uikit_integration_def.js +25 -9
  30. package/tools/definitions/get_native_call_uikit_integration_def.js.map +1 -1
  31. package/tools/definitions/get_native_chat_uikit_integration_def.js +36 -14
  32. package/tools/definitions/get_native_chat_uikit_integration_def.js.map +1 -1
  33. package/tools/definitions/get_native_live_uikit_integration_def.js +55 -29
  34. package/tools/definitions/get_native_live_uikit_integration_def.js.map +1 -1
  35. package/tools/definitions/get_native_live_uikit_interaction_def.js +43 -54
  36. package/tools/definitions/get_native_live_uikit_interaction_def.js.map +1 -1
  37. package/tools/definitions/get_web_room_feature_detail_def.js +52 -55
  38. package/tools/definitions/get_web_room_feature_detail_def.js.map +1 -1
  39. package/tools/definitions/get_web_room_uikit_integration_def.js +41 -25
  40. package/tools/definitions/get_web_room_uikit_integration_def.js.map +1 -1
  41. package/tools/definitions/present_scenario_choice_def.js +53 -0
  42. package/tools/definitions/present_scenario_choice_def.js.map +1 -0
  43. package/tools/definitions/record_prompt_def.js +26 -21
  44. package/tools/definitions/record_prompt_def.js.map +1 -1
  45. package/tools/definitions/record_result_def.js +20 -4
  46. package/tools/definitions/record_result_def.js.map +1 -1
  47. package/tools/index.js +2 -0
  48. package/tools/index.js.map +1 -1
  49. package/tools/live/get-native-live-uikit-integration.js +110 -34
  50. package/tools/live/get-native-live-uikit-integration.js.map +1 -1
  51. package/tools/live/get_native_live_uikit_interaction.js +128 -35
  52. package/tools/live/get_native_live_uikit_interaction.js.map +1 -1
  53. package/utils/report-cls-client.js +1 -1
  54. package/utils/report-es-client.js +1 -1
@@ -0,0 +1,339 @@
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
+ ![](https://write-document-release-1258344699.cos.ap-guangzhou.tencentcos.cn/100027182498/9013fb14c6b611f087ad52540099c741.png)
4
+
5
+
6
+ ## Core Features
7
+ - **Real-Time Audience List**: Fetch and display the list of users currently in the room.
8
+
9
+ - **Audience Statistics**: Get the real-time total viewer count.
10
+
11
+ - **Event Monitoring**: Listen for events when viewers join or leave the room.
12
+
13
+ - **Role Management**: The host can grant or revoke administrator privileges for viewers.
14
+
15
+ - **Room Management**: The host or administrator can remove specific viewers from the live room.
16
+
17
+
18
+ ## Core Concepts
19
+ <table>
20
+ <tr>
21
+ <td rowspan="1" colSpan="1" >**Core Concept**</td>
22
+
23
+ <td rowspan="1" colSpan="1" >**Type**</td>
24
+
25
+ <td rowspan="1" colSpan="1" >**Core Responsibilities & Description**</td>
26
+ </tr>
27
+
28
+ <tr>
29
+ <td rowspan="1" colSpan="1" >`LiveUserInfo`</td>
30
+
31
+ <td rowspan="1" colSpan="1" >`class`</td>
32
+
33
+ <td rowspan="1" colSpan="1" >- Data model representing a viewer.<br>- Contains basic profile information such as userID, userName, and avatarURL.</td>
34
+ </tr>
35
+
36
+ <tr>
37
+ <td rowspan="1" colSpan="1" >`LiveAudienceState`</td>
38
+
39
+ <td rowspan="1" colSpan="1" >`struct`</td>
40
+
41
+ <td rowspan="1" colSpan="1" >- State container for the audience module.<br>- Exposes `audienceList` (StateFlow) for the real-time user list and `audienceCount` for the total viewer count.</td>
42
+ </tr>
43
+
44
+ <tr>
45
+ <td rowspan="1" colSpan="1" >`LiveAudienceEvent`</td>
46
+
47
+ <td rowspan="1" colSpan="1" >`enum`</td>
48
+
49
+ <td rowspan="1" colSpan="1" >- Event listener for audience changes.<br>- Provides callbacks like `.onAudienceJoined` and` .onAudienceLeft` to handle incremental list updates.</td>
50
+ </tr>
51
+
52
+ <tr>
53
+ <td rowspan="1" colSpan="1" >`LiveAudienceStore`</td>
54
+
55
+ <td rowspan="1" colSpan="1" >`class`</td>
56
+
57
+ <td rowspan="1" colSpan="1" >- Primary interface for audience management.<br>- Used to fetch list snapshots, perform admin operations (e.g., kicking users), and subscribe to real-time events.</td>
58
+ </tr>
59
+ </table>
60
+
61
+
62
+ ## Implementation
63
+
64
+ ### Step 1: Component Integration
65
+ - **Video Live Streaming**: Please refer to [Quick Start](https://write.woa.com/document/194571606121816064) to integrate AtomicXCore.
66
+
67
+ - **Voice Chat Room**: Please refer to [Quick Start](https://write.woa.com/document/194571595685527552) to integrate AtomicXCore.
68
+
69
+
70
+ ### Step 2: Initialize and Retrieve the Audience List
71
+
72
+ Get a `LiveAudienceStore` instance linked to the `liveId` and fetch the initial audience snapshot.
73
+ ``` swift
74
+ import Foundation
75
+ import AtomicXCore
76
+ import Combine
77
+
78
+ class AudienceManager {
79
+ private let liveId: String
80
+ private let audienceStore: LiveAudienceStore
81
+ private var cancellables = Set<AnyCancellable>()
82
+
83
+ // Expose the [full] audience list publisher for UI layer subscription
84
+ let audienceListPublisher = CurrentValueSubject<[LiveUserInfo], Never>([])
85
+ // Expose the audience count publisher
86
+ let audienceCountPublisher = PassthroughSubject<UInt, Never>()
87
+
88
+ init(liveId: String) {
89
+ self.liveId = liveId
90
+ // 1. Get the LiveAudienceStore instance by liveId
91
+ self.audienceStore = LiveAudienceStore.create(liveID: liveId)
92
+
93
+ // 2. Subscribe to state and events
94
+ subscribeToAudienceState()
95
+ subscribeToAudienceEvents()
96
+
97
+ // 3. Proactively fetch initial data for the first screen
98
+ fetchInitialAudienceList()
99
+ }
100
+
101
+ /// Proactively fetch a snapshot of the audience list
102
+ func fetchInitialAudienceList() {
103
+ audienceStore.fetchAudienceList { [weak self] result in
104
+ switch result {
105
+ case .success:
106
+ print("Successfully fetched the audience list for the first time")
107
+ // On success, data will be automatically updated via the state subscription channel below
108
+ case .failure(let error):
109
+ print("Failed to fetch the audience list for the first time: \(error.localizedDescription)")
110
+ }
111
+ }
112
+ }
113
+
114
+ // ... subsequent code
115
+ }
116
+ ```
117
+
118
+ ### Step 3: Subscribe to State and Events
119
+
120
+ Observe the `audienceStore` state and listen for events to receive list snapshots and real-time join/leave updates
121
+ ``` swift
122
+ extension AudienceManager {
123
+ /// Subscribe to state to get audience count and list snapshot
124
+ private func subscribeToAudienceState() {
125
+ audienceStore.state
126
+ .subscribe()
127
+ .receive(on: DispatchQueue.main)
128
+ .sink { [weak self] state in
129
+ // state.audienceList is a full snapshot
130
+ self?.audienceListPublisher.send(state.audienceList)
131
+ // state.audienceCount is the real-time total
132
+ self?.audienceCountPublisher.send(state.audienceCount)
133
+ }
134
+ .store(in: &cancellables)
135
+ }
136
+
137
+ /// Subscribe to events to handle real-time audience join/leave
138
+ private func subscribeToAudienceEvents() {
139
+ audienceStore.liveAudienceEventPublisher
140
+ .receive(on: DispatchQueue.main)
141
+ .sink { [weak self] event in
142
+ guard let self = self else { return }
143
+
144
+ var currentList = self.audienceListPublisher.value
145
+
146
+ switch event {
147
+ case .onAudienceJoined(let newAudience):
148
+ print("Audience \(newAudience.userName) joined the live room")
149
+ // Incremental update: add the new audience member to the end of the current list
150
+ if !currentList.contains(where: { $0.userID == newAudience.userID }) {
151
+ currentList.append(newAudience)
152
+ self.audienceListPublisher.send(currentList)
153
+ }
154
+
155
+ case .onAudienceLeft(let departedAudience):
156
+ print("Audience \(departedAudience.userName) left the live room")
157
+ // Incremental update: remove the departed audience member from the current list
158
+ currentList.removeAll { $0.userID == departedAudience.userID }
159
+ self.audienceListPublisher.send(currentList)
160
+ }
161
+ }
162
+ .store(in: &cancellables)
163
+ }
164
+ }
165
+ ```
166
+
167
+ ### Step 4: Manage Audience
168
+
169
+ As a host or administrator, you can manage viewers in the live room.
170
+
171
+ #### 4.1 Kick a Viewer Out of the Live Room
172
+
173
+ Call the `kickUserOutOfRoom` API to remove a specified user from the live room.
174
+ ``` swift
175
+ extension AudienceManager {
176
+ func kick(userId: String) {
177
+ audienceStore.kickUserOutOfRoom(userID: userId) { result in
178
+ switch result {
179
+ case .success:
180
+ print("Successfully kicked user \(userId) out of the room")
181
+ // After a successful kick, you will receive an onAudienceLeft event
182
+ case .failure(let error):
183
+ print("Failed to kick user \(userId) out: \(error.localizedDescription)")
184
+ }
185
+ }
186
+ }
187
+ }
188
+ ```
189
+
190
+ #### 4.2 Manage Admin Roles
191
+
192
+ Use the `setAdministrator` and `revokeAdministrator` APIs to grant or revoke administrator privileges for a user.
193
+ ``` swift
194
+ extension AudienceManager {
195
+ /// Promote user to administrator
196
+ func promoteToAdmin(userId: String) {
197
+ audienceStore.setAdministrator(userID: userId) { result in
198
+ if case .success = result {
199
+ print("Successfully promoted user \(userId) to administrator")
200
+ }
201
+ }
202
+ }
203
+
204
+ /// Revoke user's administrator status
205
+ func revokeAdmin(userId: String) {
206
+ audienceStore.revokeAdministrator(userID: userId) { result in
207
+ if case .success = result {
208
+ print("Successfully revoked administrator status for user \(userId)")
209
+ }
210
+ }
211
+ }
212
+ }
213
+ ```
214
+
215
+ ## Advanced Features
216
+
217
+ ### Display Welcome Message on Entry
218
+
219
+ When a new audience member enters the live room, a welcome message is automatically displayed locally in the barrage/chat area, such as: `"Welcome [User Nickname] to the live room"`.
220
+
221
+ #### Implementation
222
+ 1. Listen for Join Events: Observe the `LiveAudienceEvent.onAudienceJoined` callback in `LiveAudienceStore` to receive real-time notifications when a new user enters.
223
+
224
+ 2. Insert Local Message: Upon triggering the event, extract the user's nickname and immediately call the `appendLocalTip` API in BarrageStore to insert the system message locally.
225
+
226
+ ``` swift
227
+ import Foundation
228
+ import AtomicXCore
229
+ import Combine
230
+
231
+ class LiveRoomManager {
232
+ private let liveId: String
233
+ private let audienceManager: AudienceManager
234
+ private let barrageManager: BarrageManager // Assume you have implemented BarrageManager as described in the barrage documentation
235
+ private var cancellables = Set<AnyCancellable>()
236
+
237
+ init(liveId: String) {
238
+ self.liveId = liveId
239
+ // Initialize two core managers
240
+ self.audienceManager = AudienceManager(liveId: liveId)
241
+ self.barrageManager = BarrageManager(liveId: liveId)
242
+
243
+ // Set up linkage
244
+ setupWelcomeMessageFlow()
245
+ }
246
+
247
+ private func setupWelcomeMessageFlow() {
248
+ // 1. Get the LiveAudienceStore instance
249
+ let audienceStore = LiveAudienceStore.create(liveID: self.liveId)
250
+
251
+ // 2. Get the BarrageStore instance (thanks to internal mechanisms, this will be the same instance)
252
+ let barrageStore = BarrageStore.create(liveID: self.liveId)
253
+
254
+ // 3. Subscribe to audience events
255
+ audienceStore.liveAudienceEventPublisher
256
+ .receive(on: DispatchQueue.main)
257
+ .sink { event in
258
+ // 4. Only handle audience join events
259
+ guard case .onAudienceJoined(let newAudience) = event else {
260
+ return
261
+ }
262
+
263
+ // 5. Create a local tip message
264
+ var welcomeTip = Barrage()
265
+ welcomeTip.messageType = .text
266
+ welcomeTip.textContent = "Welcome \(newAudience.userName) to the live room!"
267
+
268
+ // 6. Call BarrageStore's API to insert it into the barrage list
269
+ barrageStore.appendLocalTip(message: welcomeTip)
270
+ }
271
+ .store(in: &cancellables)
272
+ }
273
+ }
274
+ ```
275
+
276
+ ## API Documentation
277
+
278
+ For detailed information on all public interfaces, properties, and methods of [LiveAudienceStore](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveaudiencestore) and its related classes, refer to the official API documentation included with the [AtomicX Core](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore) framework. The relevant Stores used in this document are as follows:
279
+ <table>
280
+ <tr>
281
+ <td rowspan="1" colSpan="1" >**Store/Component**</td>
282
+
283
+ <td rowspan="1" colSpan="1" >**Feature Description**</td>
284
+
285
+ <td rowspan="1" colSpan="1" >**API Documentation**</td>
286
+ </tr>
287
+
288
+ <tr>
289
+ <td rowspan="1" colSpan="1" >LiveCoreView</td>
290
+
291
+ <td rowspan="1" colSpan="1" >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.</td>
292
+
293
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/livecoreview)</td>
294
+ </tr>
295
+
296
+ <tr>
297
+ <td rowspan="1" colSpan="1" >LiveAudienceStore</td>
298
+
299
+ <td rowspan="1" colSpan="1" >Audience management: obtain real-time audience list (ID / name / avatar), count audience numbers, and listen for audience join/leave events.</td>
300
+
301
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/liveaudiencestore)</td>
302
+ </tr>
303
+
304
+ <tr>
305
+ <td rowspan="1" colSpan="1" >BarrageStore</td>
306
+
307
+ <td rowspan="1" colSpan="1" >Barrage feature: send text/custom barrage, maintain barrage list, and listen to barrage status in real time.</td>
308
+
309
+ <td rowspan="1" colSpan="1" >[API Documentation](https://tencent-rtc.github.io/TUIKit_iOS/documentation/atomicxcore/barragestore)</td>
310
+ </tr>
311
+ </table>
312
+
313
+
314
+ ## FAQs
315
+
316
+ ### How is the online audience count (audienceCount) in LiveAudienceState updated? What are the timing and frequency?
317
+
318
+ The `audienceCount` is a high-precision estimate. Updates occur based on specific triggers and are subject to system frequency controls:
319
+ - **Active Entry/Exit (Immediate)**:When a user explicitly joins or leaves the room, the count updates immediately in `LiveAudienceState`.
320
+
321
+ - **Unexpected Disconnection (Delayed)**:If a user disconnects abnormally (e.g., app crash, network loss), the system uses a heartbeat mechanism to verify status. The user is marked offline only after 90 seconds of inactivity, triggering a delayed count update.
322
+
323
+ - **Frequency Control & Rate Limiting**: Audience count updates are broadcast as room messages. The system enforces a limit of 40 messages per second per room.
324
+
325
+
326
+ > **Note:**
327
+ >
328
+
329
+ > During high-traffic spikes (e.g., chat floods or rapid gifting), if the message rate exceeds this threshold, the system prioritizes core messages (like chat/barrage). Consequently, audience count update messages may be dropped to maintain stability.
330
+ >
331
+
332
+ - **What does this mean for developers?**
333
+
334
+
335
+ Treat `audienceCount` as a metric for UI display purposes only. Do not rely on it for billing, critical statistics, or scenarios requiring 100% accuracy, as brief delays or data loss may occur during high-concurrency events.
336
+
337
+
338
+
339
+