@tencent-rtc/mcp 1.3.0 → 1.3.2
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.
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/resource/doc/chatuikit/faq/web_sdk/faq.md +125 -0
- package/resource/doc/chatuikit/flutter/faq.md +17 -114
- package/resource/doc/chatuikit/flutter/integrate_tuikit_Flutter.md +86 -722
- package/resource/doc/chatuikit/react/integration.md +430 -49
- package/resource/doc/chatuikit/react/workflow.md +258 -0
- package/resource/doc/chatuikit/vue/integration.md +355 -144
- package/resource/doc/chatuikit/vue/workflow.md +395 -0
- package/resource/doc/roomkit/vue/features/call-user-to-room.md +256 -0
- package/resource/doc/roomkit/vue/features/device-detection.md +388 -0
- package/resource/doc/roomkit/vue/features/device-state.md +480 -0
- package/resource/doc/roomkit/vue/features/free-beauty-panel.md +238 -0
- package/resource/doc/roomkit/vue/features/room-chat.md +427 -0
- package/resource/doc/roomkit/vue/features/room-participant-state.md +407 -0
- package/resource/doc/roomkit/vue/features/room-state.md +291 -0
- package/resource/doc/roomkit/vue/features/room-view.md +338 -0
- package/resource/doc/roomkit/vue/features/schedule-room.md +349 -0
- package/resource/doc/roomkit/vue/features/screen-share.md +333 -0
- package/resource/doc/roomkit/vue/features/virtual-background.md +287 -0
- package/resource/doc/roomkit/vue/features/workflow.md +553 -0
- package/resource/doc/roomkit/vue/integration.md +479 -0
- package/resource/doc/roomkit/vue/workflow.md +487 -0
- package/resource/doc/tuicallkit/react/api.md +21 -0
- package/resource/doc/tuicallkit/vue/api.md +21 -0
- package/tools/chat/get-web-chat-integration.js +31 -14
- package/tools/chat/get-web-chat-integration.js.map +1 -1
- package/tools/definitions/get_web_chat_uikit_integration_def.js +19 -12
- package/tools/definitions/get_web_chat_uikit_integration_def.js.map +1 -1
- package/tools/definitions/get_web_room_feature_detail_def.js +95 -0
- package/tools/definitions/get_web_room_feature_detail_def.js.map +1 -0
- package/tools/definitions/get_web_room_uikit_integration_def.js +44 -0
- package/tools/definitions/get_web_room_uikit_integration_def.js.map +1 -0
- package/tools/index.js +4 -4
- package/tools/index.js.map +1 -1
- package/tools/live/get-web-live-uikit-integration.js +1 -1
- package/tools/room/get-web-room-feature-detail.js +68 -0
- package/tools/room/get-web-room-feature-detail.js.map +1 -0
- package/tools/room/get-web-room-integration.js +43 -0
- package/tools/room/get-web-room-integration.js.map +1 -0
- package/utils/generate-structured-result.js +2 -2
- package/utils/generate-structured-result.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- package/resource/doc/chatuikit/flutter/integrate_only_tuichat_Flutter.md +0 -333
- package/resource/doc/chatuikit/flutter/quick_start_Flutter.md +0 -217
- package/resource/doc/chatuikit/react/chat_window_integration.md +0 -94
- package/resource/doc/chatuikit/vue/chat_window_integration.md +0 -156
- package/resource/doc/roomkit/vue/states/device-state.md +0 -369
- package/resource/doc/roomkit/vue/states/login-state.md +0 -59
- package/resource/doc/roomkit/vue/states/room-list-state.md +0 -355
- package/resource/doc/roomkit/vue/states/room-participant-state.md +0 -388
- package/tools/chat/get-web-chat-window-integration.js +0 -28
- package/tools/chat/get-web-chat-window-integration.js.map +0 -1
- package/tools/definitions/get_web_chat_window_integration_def.js +0 -26
- package/tools/definitions/get_web_chat_window_integration_def.js.map +0 -1
- package/tools/room/get-web-room-state-detail.js +0 -31
- package/tools/room/get-web-room-state-detail.js.map +0 -1
|
@@ -0,0 +1,553 @@
|
|
|
1
|
+
# RoomKit Feature Custom UI Workflow Instructions
|
|
2
|
+
|
|
3
|
+
## 📋 Instruction Purpose
|
|
4
|
+
|
|
5
|
+
Provide agents with a code generation blueprint for implementing audio/video conferencing features using **RoomKit atomic API/Hooks** for customization. This instruction is specifically designed for scenarios where **the complete TUIRoomKit page is not used**, but UI is built based on atomic capabilities.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🎯 Applicable Scenarios
|
|
10
|
+
|
|
11
|
+
This workflow is applicable to the following scenarios:
|
|
12
|
+
|
|
13
|
+
- H5/Mobile audio/video conferencing application development
|
|
14
|
+
- PC Web audio/video conferencing application development
|
|
15
|
+
- Customizing conference UI using RoomKit atomic capabilities
|
|
16
|
+
- Integrating specific feature modules (screen sharing, beauty effects, chat, etc.) into existing applications
|
|
17
|
+
- Deep customization of conference interface or business processes
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🛑 Core Constraints and Specifications
|
|
22
|
+
|
|
23
|
+
### 1. Login and Authentication (Prerequisites)
|
|
24
|
+
|
|
25
|
+
**🔐 Core Principle**: In Feature custom UI mode, **must use `get_usersig` tool + `useLoginState` Hook for login authentication**, manual UserSig generation code is prohibited.
|
|
26
|
+
|
|
27
|
+
#### Why Login is Required?
|
|
28
|
+
|
|
29
|
+
Before using TUIRoomKit's atomic APIs (useRoomState, useDeviceState, etc.), login authentication must be completed:
|
|
30
|
+
- **Identity Verification**: Ensure users have permission to use Tencent Cloud TRTC service
|
|
31
|
+
- **SDK Initialization**: SDK can only work properly after successful login
|
|
32
|
+
- **Data Synchronization**: Can only receive real-time data such as rooms and members after login
|
|
33
|
+
|
|
34
|
+
#### Login Code Example
|
|
35
|
+
|
|
36
|
+
```vue
|
|
37
|
+
<script setup lang="ts">
|
|
38
|
+
import { useLoginState } from 'tuikit-atomicx-vue3';
|
|
39
|
+
|
|
40
|
+
// Standard usage: destructure required methods and states
|
|
41
|
+
const { login, loginUserInfo } = useLoginState();
|
|
42
|
+
|
|
43
|
+
async function performLogin() {
|
|
44
|
+
try {
|
|
45
|
+
// Login with information returned by get_usersig tool
|
|
46
|
+
await login({
|
|
47
|
+
sdkAppId: YOUR_SDK_APP_ID, // From get_usersig tool
|
|
48
|
+
userId: YOUR_USER_ID, // From get_usersig tool
|
|
49
|
+
userSig: YOUR_USER_SIG, // From get_usersig tool
|
|
50
|
+
});
|
|
51
|
+
console.log('Login successful, userID:', loginUserInfo.value?.userID);
|
|
52
|
+
// After successful login, other feature modules can be used
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error('Login failed:', error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
#### Mandatory Constraints and Specifications
|
|
61
|
+
|
|
62
|
+
| Constraint | Requirement | Description |
|
|
63
|
+
|--------|------|------|
|
|
64
|
+
| **UserID Generation Rules** | ✅ **Format**: `userXXX` (XXX is digits)<br>✅ **Example**: `user123`, `user001`, `user999`<br>❌ **Prohibited** to use special connectors (such as `user_123`, `user-001`) | Use simple userID format in test environment for easy identification and debugging |
|
|
65
|
+
| **UserSig Generation (Mandatory)** | ✅ **Must** use `get_usersig` MCP tool to generate<br>❌ **Strictly Prohibited** to write `generateUserSig` function in project<br>❌ **Strictly Prohibited** to import `GenerateTestUserSig` class in project<br>❌ **Strictly Prohibited** to write any UserSig generation logic | **Integration testing must use get_usersig tool**, Agent can only call this tool to obtain UserSig, and must not generate any related code |
|
|
66
|
+
| **Login API** | ✅ **Must** use login method of `useLoginState` Hook<br>❌ **Prohibited** to directly call SDK underlying API | Use atomic Hook's API, do not directly operate TUIRoomEngine |
|
|
67
|
+
| **Login Timing** | ✅ **Must** complete login before using any other features<br>⚠️ Login failure will cause all features to be unavailable | Recommended to complete login at application startup or before entering meeting |
|
|
68
|
+
| **Security Reminder** | ⚠️ **Must** inform users:<br>• Client-generated UserSig is only for development testing<br>• Production environment must generate UserSig on server side<br>• Do not expose secretKey in client code | UserSig contains user identity information and must be kept secure |
|
|
69
|
+
|
|
70
|
+
#### UserSig Generation Mandatory Specifications (Important)
|
|
71
|
+
|
|
72
|
+
**Core Principle**: **During integration testing, UserSig must be generated by `get_usersig` MCP tool, strictly prohibit implementing any UserSig generation logic in project code**.
|
|
73
|
+
|
|
74
|
+
##### ✅ Correct Approach: Use get_usersig Tool
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// ✅ Correct: Agent calls get_usersig tool to obtain credentials
|
|
78
|
+
// Tool returns: { sdkAppId: 1400xxx, userId: 'user123', userSig: 'eJw...' }
|
|
79
|
+
|
|
80
|
+
// Use values returned by tool directly in project code
|
|
81
|
+
const { login } = useLoginState();
|
|
82
|
+
|
|
83
|
+
await login({
|
|
84
|
+
sdkAppId: 1400188366, // From get_usersig tool
|
|
85
|
+
userId: 'user123', // From get_usersig tool
|
|
86
|
+
userSig: 'eJw1jdEKgj...', // From get_usersig tool
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
##### ❌ Wrong Approach: Generate UserSig in Project
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
// ❌ Strictly Prohibited: Write generateUserSig function
|
|
94
|
+
function generateUserSig(userId: string) {
|
|
95
|
+
const SDKAPPID = 1400188366;
|
|
96
|
+
const SECRETKEY = 'your-secret-key';
|
|
97
|
+
// ... HMAC-SHA256 algorithm implementation
|
|
98
|
+
return userSig;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ❌ Strictly Prohibited: Import GenerateTestUserSig class
|
|
102
|
+
import GenerateTestUserSig from './debug/GenerateTestUserSig';
|
|
103
|
+
const { userSig } = GenerateTestUserSig.genTestUserSig(userId);
|
|
104
|
+
|
|
105
|
+
// ❌ Strictly Prohibited: Import UserSig generation logic from any file
|
|
106
|
+
import { createUserSig } from './utils/usersig';
|
|
107
|
+
|
|
108
|
+
// ❌ Strictly Prohibited: Any form of UserSig generation code
|
|
109
|
+
const userSig = crypto.createHmac('sha256', SECRETKEY).update(data).digest('base64');
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Why Prohibited**:
|
|
113
|
+
1. **Security Risk**: Including secretKey in project will cause key leakage
|
|
114
|
+
2. **Against Best Practices**: Integration testing should use tools, production environment should use server-side API
|
|
115
|
+
3. **Misleading Users**: Easy to make users think client-generated UserSig is the correct approach
|
|
116
|
+
|
|
117
|
+
**Agent Behavior Constraints**:
|
|
118
|
+
- ✅ **Must** call `get_usersig` MCP tool to obtain UserSig
|
|
119
|
+
- ✅ **Must** explain in code comments that these values come from get_usersig tool
|
|
120
|
+
- ❌ **Strictly Prohibited** to generate any code containing `generateUserSig`, `GenerateTestUserSig`, `SECRETKEY`
|
|
121
|
+
- ❌ **Strictly Prohibited** to create any utility functions or classes related to UserSig generation
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
### 2. Documentation-Driven Development
|
|
126
|
+
|
|
127
|
+
- ✅ **Strictly follow** the content of feature documentation returned this time
|
|
128
|
+
- ✅ **Prioritize using** code examples and best practices in documentation
|
|
129
|
+
- ❌ **Prohibited to arbitrarily modify** API calling methods and parameters provided in documentation
|
|
130
|
+
- ⚠️ **Prohibited to use APIs from memory**: Must follow feature documentation, do not use outdated APIs from training data
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### 3. API Version Constraints (Important)
|
|
135
|
+
|
|
136
|
+
**Core Principle**: **Strictly use APIs listed in feature documentation, prohibit using any API names not appearing in documentation**.
|
|
137
|
+
|
|
138
|
+
#### API Usage Process (Must Follow)
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
1. Check API list in feature documentation returned this time
|
|
142
|
+
↓
|
|
143
|
+
2. Confirm API signature and usage against official API documentation
|
|
144
|
+
↓
|
|
145
|
+
3. Generate code using APIs explicitly listed in documentation
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Official API Documentation**:
|
|
149
|
+
- 📚 **TUIRoomKit API Reference**: https://web.sdk.qcloud.com/trtc/live/web/doc/zh/index.html
|
|
150
|
+
- ⚠️ **Any API usage must confirm its existence and signature in this documentation first**
|
|
151
|
+
|
|
152
|
+
**Mandatory Constraints**:
|
|
153
|
+
1. ✅ **Must** follow API list in feature documentation
|
|
154
|
+
2. ✅ **Must** confirm API existence in official documentation (https://web.sdk.qcloud.com/trtc/live/web/doc/zh/index.html)
|
|
155
|
+
3. ❌ **Prohibited** to use API names from training data or memory
|
|
156
|
+
4. ❌ **Prohibited** to use APIs not listed in feature documentation
|
|
157
|
+
5. ⚠️ If an API is not listed in feature documentation, it means the API is deprecated or does not exist
|
|
158
|
+
|
|
159
|
+
**API Verification Checklist**:
|
|
160
|
+
- [ ] API name explicitly listed in feature documentation?
|
|
161
|
+
- [ ] API exists in official documentation?
|
|
162
|
+
- [ ] API signature consistent with official documentation?
|
|
163
|
+
- [ ] Not using outdated APIs from memory?
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## 📚 RoomKit State API Architecture Description
|
|
168
|
+
|
|
169
|
+
> **Note**: This section explains TUIRoomKit (Atomicx version) State API architecture and usage specifications. For detailed API parameters and code examples, please refer to specific feature documentation.
|
|
170
|
+
|
|
171
|
+
### 🔍 API Architecture Overview
|
|
172
|
+
|
|
173
|
+
TUIRoomKit Atomicx version adopts Reactive design, dividing features into different State modules. Each module provides reactive data and operation methods through `use[StateName]` Hook.
|
|
174
|
+
|
|
175
|
+
**Core Design Concept**:
|
|
176
|
+
- ✅ **Reactive Data**: All states are Vue 3 Refs, can be directly used in templates or monitored through `watch`
|
|
177
|
+
- ✅ **Modular Destructuring**: Destructure required methods and states as needed to avoid introducing unnecessary dependencies
|
|
178
|
+
- ✅ **Standard Calling Method**: `const { method, state } = useXxxState()`
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
### 📝 Usage Specifications (Important)
|
|
183
|
+
|
|
184
|
+
#### 1. Standard Destructuring Method
|
|
185
|
+
|
|
186
|
+
✅ **Correct**:
|
|
187
|
+
```typescript
|
|
188
|
+
const { login, loginUserInfo } = useLoginState();
|
|
189
|
+
await login({ sdkAppId, userId, userSig });
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
❌ **Wrong**:
|
|
193
|
+
```typescript
|
|
194
|
+
const loginState = useLoginState();
|
|
195
|
+
await loginState.login({ sdkAppId, userId, userSig });
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
#### 2. Reactive Data Access
|
|
199
|
+
|
|
200
|
+
✅ **Correct**:
|
|
201
|
+
```typescript
|
|
202
|
+
const { loginUserInfo } = useLoginState();
|
|
203
|
+
|
|
204
|
+
// Access in setup
|
|
205
|
+
if (loginUserInfo.value) {
|
|
206
|
+
console.log(loginUserInfo.value.userID);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Access in template (auto unwrap)
|
|
210
|
+
<template>
|
|
211
|
+
<div v-if="loginUserInfo">
|
|
212
|
+
{{ loginUserInfo.userID }}
|
|
213
|
+
</div>
|
|
214
|
+
</template>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
❌ **Wrong**:
|
|
218
|
+
```typescript
|
|
219
|
+
// Forget to use .value
|
|
220
|
+
if (loginUserInfo) { // ❌ loginUserInfo is a Ref object, not a boolean
|
|
221
|
+
console.log(loginUserInfo.userID); // ❌ Cannot access
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
#### 3. State Monitoring
|
|
226
|
+
|
|
227
|
+
```typescript
|
|
228
|
+
import { watch } from 'vue';
|
|
229
|
+
const { loginUserInfo } = useLoginState();
|
|
230
|
+
|
|
231
|
+
// Monitor login state changes
|
|
232
|
+
watch(loginUserInfo, (newInfo, oldInfo) => {
|
|
233
|
+
if (newInfo) {
|
|
234
|
+
console.log('User logged in:', newInfo.userID);
|
|
235
|
+
} else {
|
|
236
|
+
console.log('User logged out');
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
### 🔗 Reference Resources
|
|
244
|
+
|
|
245
|
+
- **Official API Documentation**: https://web.sdk.qcloud.com/trtc/live/web/doc/zh/index.html
|
|
246
|
+
- **Detailed Code Examples**: Refer to specific feature documentation of each feature module
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 🏗️ General Integration Steps
|
|
251
|
+
|
|
252
|
+
#### Step 1: Install Dependencies
|
|
253
|
+
|
|
254
|
+
**Core Dependencies**:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"tuikit-atomicx-vue3": "latest", // TUIRoomKit atomic component library (contains all Hooks and UI components, will automatically install tuiroom-engine-js)
|
|
259
|
+
"@tencentcloud/uikit-base-component-vue3": "latest", // Basic UI component library (common components like buttons, input boxes)
|
|
260
|
+
"vue-router": "^4.0.0" // Vue router (for page navigation, install when router functionality is needed)
|
|
261
|
+
}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Dependency Description**:
|
|
265
|
+
- **tuikit-atomicx-vue3**: Core package, contains all atomic Hooks and UI components, will automatically install `@tencentcloud/tuiroom-engine-js`
|
|
266
|
+
- **@tencentcloud/uikit-base-component-vue3**: Basic UI component library (install when using TUIKit UI components)
|
|
267
|
+
- **vue-router**: Vue router library (install when implementing page navigation)
|
|
268
|
+
|
|
269
|
+
**Installation Commands**:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Minimal installation (core package only)
|
|
273
|
+
npm install tuikit-atomicx-vue3
|
|
274
|
+
|
|
275
|
+
# Full installation (including UI component library and router)
|
|
276
|
+
npm install tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3 vue-router
|
|
277
|
+
|
|
278
|
+
# Or use pnpm
|
|
279
|
+
pnpm install tuikit-atomicx-vue3
|
|
280
|
+
pnpm install tuikit-atomicx-vue3 @tencentcloud/uikit-base-component-vue3 vue-router
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Build Environment Patch (Vite Projects)**:
|
|
284
|
+
|
|
285
|
+
If Vite project is detected, Agent must automatically add patch configuration to `package.json` for esbuild-wasm compatibility:
|
|
286
|
+
|
|
287
|
+
```json
|
|
288
|
+
{
|
|
289
|
+
"overrides": {
|
|
290
|
+
"esbuild": "npm:esbuild-wasm@latest" // npm uses this field to override dependency versions
|
|
291
|
+
},
|
|
292
|
+
"resolutions": {
|
|
293
|
+
"esbuild": "npm:esbuild-wasm@latest" // yarn/pnpm uses this field to override dependency versions
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Patch Description**:
|
|
299
|
+
- **Why Needed**: In some environments, esbuild native binaries may not run properly, using esbuild-wasm (WebAssembly version) can provide better cross-platform compatibility
|
|
300
|
+
- **Applicable Scenarios**: Mainly for projects using Vite build tool
|
|
301
|
+
- **Function**: Force replace all esbuild versions in project dependencies with esbuild-wasm version
|
|
302
|
+
|
|
303
|
+
#### Step 2: Login Authentication (Prerequisites)
|
|
304
|
+
|
|
305
|
+
Login must be completed before using all feature modules. Please refer to examples in specific feature documentation for detailed code.
|
|
306
|
+
|
|
307
|
+
#### Step 3: Import and Use Feature Hooks
|
|
308
|
+
|
|
309
|
+
All Hooks are imported from `tuikit-atomicx-vue3`. Please refer to feature documentation for specific API calling methods.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 🎨 Code Generation Specifications
|
|
314
|
+
|
|
315
|
+
### 1. Vue 3 Composition API
|
|
316
|
+
|
|
317
|
+
- Use `<script setup lang="ts">` syntax
|
|
318
|
+
- Use Vue 3 Composition API (ref, reactive, computed, onMounted, etc.)
|
|
319
|
+
- Import required Hooks from `tuikit-atomicx-vue3`
|
|
320
|
+
|
|
321
|
+
### 2. TypeScript Type Safety
|
|
322
|
+
|
|
323
|
+
- Use official type definitions (import from `@tencentcloud/tuiroom-engine-js`)
|
|
324
|
+
- Add correct type annotations for state variables
|
|
325
|
+
|
|
326
|
+
### 3. Error Handling
|
|
327
|
+
|
|
328
|
+
- All asynchronous operations must use try-catch for error handling
|
|
329
|
+
- Provide friendly error prompts
|
|
330
|
+
|
|
331
|
+
### 4. Microphone Switch Best Practices (Important)
|
|
332
|
+
|
|
333
|
+
#### Core Principle
|
|
334
|
+
|
|
335
|
+
**Physically open microphone only once when entering room, use mute/unmute for switching during meeting**.
|
|
336
|
+
|
|
337
|
+
#### Implementation Method
|
|
338
|
+
|
|
339
|
+
| Scenario | API Call | Description |
|
|
340
|
+
|------|---------|------|
|
|
341
|
+
| **Open Microphone When Entering Room** | `await openLocalMicrophone()`<br>`await unmuteLocalAudio()` | Physically open microphone device and unmute |
|
|
342
|
+
| **Close Microphone During Meeting** | `await muteLocalAudio()` | Only mute, do not close physical device |
|
|
343
|
+
| **Open Microphone During Meeting** | `await unmuteLocalAudio()` | Only unmute, do not reopen physical device |
|
|
344
|
+
|
|
345
|
+
#### Code Example
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
import { useDeviceState } from 'tuikit-atomicx-vue3';
|
|
349
|
+
|
|
350
|
+
const { openLocalMicrophone, muteLocalAudio, unmuteLocalAudio } = useDeviceState();
|
|
351
|
+
|
|
352
|
+
// ✅ Correct: Initialize microphone when entering room
|
|
353
|
+
async function enterRoomWithMicrophone() {
|
|
354
|
+
try {
|
|
355
|
+
// 1. Join room
|
|
356
|
+
await joinRoom('room123');
|
|
357
|
+
|
|
358
|
+
// 2. Physically open microphone (only once)
|
|
359
|
+
await openLocalMicrophone();
|
|
360
|
+
|
|
361
|
+
// 3. Unmute
|
|
362
|
+
await unmuteLocalAudio();
|
|
363
|
+
} catch (error) {
|
|
364
|
+
console.error('Microphone initialization failed:', error);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// ✅ Correct: Close microphone during meeting (mute)
|
|
369
|
+
async function closeMicInRoom() {
|
|
370
|
+
try {
|
|
371
|
+
await muteLocalAudio(); // Only mute, do not close physical device
|
|
372
|
+
} catch (error) {
|
|
373
|
+
console.error('Mute failed:', error);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// ✅ Correct: Open microphone during meeting (unmute)
|
|
378
|
+
async function openMicInRoom() {
|
|
379
|
+
try {
|
|
380
|
+
await unmuteLocalAudio(); // Only unmute, do not reopen physical device
|
|
381
|
+
} catch (error) {
|
|
382
|
+
console.error('Unmute failed:', error);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// ❌ Wrong: Repeatedly call openLocalMicrophone during meeting
|
|
387
|
+
async function wrongWayToOpenMic() {
|
|
388
|
+
// Do not call during meeting, will cause delay and audio loss
|
|
389
|
+
await openLocalMicrophone(); // ❌ Wrong!
|
|
390
|
+
await unmuteLocalAudio();
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### Technical Reasons
|
|
395
|
+
|
|
396
|
+
1. **Performance Optimization**: Physically opening microphone device requires hardware initialization, takes a long time (typically 100-300ms)
|
|
397
|
+
2. **Avoid Audio Loss**: Frequently opening/closing physical devices may cause loss of first audio packets, resulting in audio loss
|
|
398
|
+
3. **User Experience**: Mute/unmute operations respond instantly without delay
|
|
399
|
+
|
|
400
|
+
#### Mandatory Constraints
|
|
401
|
+
|
|
402
|
+
- ✅ **Must** call `openLocalMicrophone()` to initialize microphone when entering room
|
|
403
|
+
- ✅ **Must** use `muteLocalAudio()` / `unmuteLocalAudio()` for microphone switching during meeting
|
|
404
|
+
- ❌ **Prohibited** to repeatedly call `openLocalMicrophone()` during meeting
|
|
405
|
+
- ❌ **Prohibited** to use `closeLocalMicrophone()` then `openLocalMicrophone()` method
|
|
406
|
+
|
|
407
|
+
### 5. Video Stream Rendering Best Practices (Recommended)
|
|
408
|
+
|
|
409
|
+
#### Core Principle
|
|
410
|
+
|
|
411
|
+
**When developing with State API, recommend using `RoomParticipantView` component to render video streams**.
|
|
412
|
+
|
|
413
|
+
#### Platform Applicability
|
|
414
|
+
|
|
415
|
+
| Component | Applicable Platforms | Description |
|
|
416
|
+
|------|---------|------|
|
|
417
|
+
| **RoomParticipantView** | ✅ H5 Mobile<br>✅ PC Web | **Priority recommendation for H5 development**, lightweight, suitable for mobile and desktop |
|
|
418
|
+
| **RoomView** | ✅ PC Web | Only for PC, includes complete meeting room layout |
|
|
419
|
+
|
|
420
|
+
**Mandatory Constraints**:
|
|
421
|
+
- ✅ **H5 Mobile Development**: Must use `RoomParticipantView` component
|
|
422
|
+
- ✅ **PC Web Development**: Priority recommendation for `RoomParticipantView` component, more flexible
|
|
423
|
+
- ⚠️ **RoomView** only for PC and scenarios requiring complete meeting room layout
|
|
424
|
+
|
|
425
|
+
#### Recommended Import Method
|
|
426
|
+
|
|
427
|
+
```typescript
|
|
428
|
+
import { RoomParticipantView } from 'tuikit-atomicx-vue3/room';
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
#### Usage Examples
|
|
432
|
+
|
|
433
|
+
##### Basic Usage: Directly Render Participant Video
|
|
434
|
+
|
|
435
|
+
```vue
|
|
436
|
+
<template>
|
|
437
|
+
<div class="video-container">
|
|
438
|
+
<!-- Render local video stream -->
|
|
439
|
+
<RoomParticipantView
|
|
440
|
+
v-if="localParticipant"
|
|
441
|
+
:participant="localParticipant"
|
|
442
|
+
:stream-type="VideoStreamType.Camera"
|
|
443
|
+
/>
|
|
444
|
+
|
|
445
|
+
<!-- Render remote video stream -->
|
|
446
|
+
<RoomParticipantView
|
|
447
|
+
v-for="user in remoteParticipants"
|
|
448
|
+
:key="user.userId"
|
|
449
|
+
:participant="user"
|
|
450
|
+
:stream-type="VideoStreamType.Camera"
|
|
451
|
+
/>
|
|
452
|
+
</div>
|
|
453
|
+
</template>
|
|
454
|
+
|
|
455
|
+
<script setup lang="ts">
|
|
456
|
+
import { RoomParticipantView, VideoStreamType } from 'tuikit-atomicx-vue3/room';
|
|
457
|
+
import { useRoomParticipantState } from 'tuikit-atomicx-vue3';
|
|
458
|
+
|
|
459
|
+
const { localParticipant, remoteParticipants } = useRoomParticipantState();
|
|
460
|
+
</script>
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
##### Advanced Usage: Distinguish Local Screen Share and Camera Stream
|
|
464
|
+
|
|
465
|
+
```vue
|
|
466
|
+
<template>
|
|
467
|
+
<LocalScreenViewUI v-if="isLocalScreen" />
|
|
468
|
+
<ParticipantViewUI
|
|
469
|
+
v-else
|
|
470
|
+
:participant="participant"
|
|
471
|
+
:stream-type="streamType"
|
|
472
|
+
/>
|
|
473
|
+
</template>
|
|
474
|
+
|
|
475
|
+
<script setup lang="ts">
|
|
476
|
+
import { computed } from 'vue';
|
|
477
|
+
import { useRoomParticipantState, VideoStreamType } from 'tuikit-atomicx-vue3/room';
|
|
478
|
+
import LocalScreenViewUI from './LocalScreenViewUI.vue';
|
|
479
|
+
import ParticipantViewUI from './ParticipantViewUI.vue';
|
|
480
|
+
import type { RoomParticipant } from 'tuikit-atomicx-vue3/room';
|
|
481
|
+
|
|
482
|
+
interface Props {
|
|
483
|
+
participant: RoomParticipant;
|
|
484
|
+
streamType: VideoStreamType;
|
|
485
|
+
}
|
|
486
|
+
const props = defineProps<Props>();
|
|
487
|
+
|
|
488
|
+
const { localParticipant } = useRoomParticipantState();
|
|
489
|
+
|
|
490
|
+
// Check if it's local screen share stream
|
|
491
|
+
const isLocalScreen = computed(() =>
|
|
492
|
+
props.participant.userId === localParticipant.value?.userId &&
|
|
493
|
+
props.streamType === VideoStreamType.Screen
|
|
494
|
+
);
|
|
495
|
+
</script>
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
#### Advantages
|
|
499
|
+
|
|
500
|
+
1. **Automatic Video Stream Management**: Component internally handles video stream subscription, rendering, and destruction
|
|
501
|
+
2. **State Synchronization**: Automatically syncs user audio/video states (mute, camera off, etc.)
|
|
502
|
+
3. **Simplified Development**: No need to manually operate DOM or manage video elements
|
|
503
|
+
4. **Best Practices**: Encapsulates best practices and optimizations for TRTC video rendering
|
|
504
|
+
|
|
505
|
+
#### Mandatory Constraints
|
|
506
|
+
|
|
507
|
+
- ✅ **Recommended** to use `RoomParticipantView` component to render video streams
|
|
508
|
+
- ✅ **Must** import from `tuikit-atomicx-vue3/room`
|
|
509
|
+
- ⚠️ For custom rendering logic, please refer to advanced usage in feature documentation
|
|
510
|
+
|
|
511
|
+
**For detailed code examples, please refer to specific feature documentation.**
|
|
512
|
+
|
|
513
|
+
---
|
|
514
|
+
|
|
515
|
+
## 🔗 Tool Reference
|
|
516
|
+
|
|
517
|
+
### `get_usersig` - Generate User Signature (Required for Login)
|
|
518
|
+
|
|
519
|
+
**Purpose**: Agent calls this MCP tool to obtain login credentials (SDKAppID, userID, userSig) for user code login calls.
|
|
520
|
+
|
|
521
|
+
**Mandatory Constraints**:
|
|
522
|
+
- ✅ Agent must call this tool to obtain login credentials
|
|
523
|
+
- ❌ Prohibited to manually write UserSig generation code
|
|
524
|
+
- ⚠️ Must inform users: UserSig should be generated on server side in production environment
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
### `record_result` - Record Integration Results
|
|
529
|
+
|
|
530
|
+
**Purpose**: Record feature integration process and results for statistical analysis
|
|
531
|
+
|
|
532
|
+
**Call Timing**: Call after completing feature integration and verification
|
|
533
|
+
|
|
534
|
+
---
|
|
535
|
+
|
|
536
|
+
## 📝 Key Points Summary
|
|
537
|
+
|
|
538
|
+
| Category | Requirement |
|
|
539
|
+
|------|------|
|
|
540
|
+
| **Applicable Scenarios** | Implement meeting UI using RoomKit atomic APIs |
|
|
541
|
+
| **Platform Support** | ✅ RoomKit State API fully supports H5 mobile and PC Web |
|
|
542
|
+
| **Login Authentication** | ✅ Must use `get_usersig` tool + `useLoginState` Hook |
|
|
543
|
+
| **API Calls** | ✅ Must use official Hooks (useRoomState, useDeviceState, etc.) |
|
|
544
|
+
| **Documentation Priority** | Strictly follow feature documentation content returned this time |
|
|
545
|
+
| **Error Handling** | All asynchronous operations must use try-catch for error handling |
|
|
546
|
+
| **Security Tips** | ⚠️ Must inform users: UserSig should be generated on server side in production environment |
|
|
547
|
+
| **Supported Frameworks** | Vue 3.4.21+ (using Composition API) |
|
|
548
|
+
|
|
549
|
+
---
|
|
550
|
+
|
|
551
|
+
**Applicable Framework**: Vue 3.4.21+
|
|
552
|
+
**Integration Mode**: Feature Custom UI (Atomic API)
|
|
553
|
+
**Platform Support**: H5 Mobile + PC Web
|