Integration
TUIRoomKit is a group audio and video room UI component that provides rich features such as room management, audio and video control, screen sharing, member management, microphone management, instant messaging, and custom layout switching. It also supports one-click switching between Chinese and English UI languages and between different app themes.
This document describes the process of integrating TUIRoomKit (Web), helping you quickly implement features for different business scenarios, such as enterprise meetings, online education, medical consultations, online inspections, and remote loss assessments.
TUIRoomKit Demo Experience
You can also visit Github to download the TUIRoomKit code and refer to the README.md file to run the TUIRoomKit Web sample project.
Environment Preparation
Node.js version: Node.js ≥ 16.19.1 (It is recommended to use the official LTS version, and the npm version should match the node version).
Modern browser, supporting WebRTC APIs.
Integrating TUIRoomKit Component
Note:
If you don't have a vue project, you can directly refer to the Run Sample Demo run through Github sample project.
If you need to integrate it into an existing project, please follow the steps below for integration.
Step 1: Install Dependencies
npm install @tencentcloud/roomkit-web-vue3 pinia --save
# Please note that the required Vue version is >= 2.7.16. If the installation fails,# please check if your Vue version is supported.npm install @tencentcloud/roomkit-web-vue2.7 pinia
Note:
TUIRoomKit package provides a pre-meeting preview component, an in-meeting component, and methods for starting meetings, joining meetings, and fine-tuning the interface. For more, see RoomKit API. If these APIs don't meet your business needs, you can refer to UIKit source code export for accessing the TUIRoomKit source code.
Step 2: Project Engineering Configuration
Register Pinia: TUIRoom uses Pinia for room data management, and you need to register Pinia in the project entry file. The project entry file is
src/main.ts
.// src/main.tsimport { createPinia } from 'pinia';const app = createApp(App);// register piniaapp.use(createPinia());app.mount('#app')
// src/main.tsimport { createPinia, PiniaVuePlugin } from 'pinia';Vue.use(PiniaVuePlugin);const pinia = createPinia();new Vue({pinia,render: h => h(App),}).$mount('#app');
Step 3: Import the TUIRoom component
Note:
Import the ConferenceMainView component, which is by default in the permanent mode (the component is always displayed, and its display and hiding are not controlled internally. If the business end does not control it, the component will always remain displayed).
<template><ConferenceMainView></ConferenceMainView></template><script setup>import { ConferenceMainView } from '@tencentcloud/roomkit-web-vue3';</script>
<template><ConferenceMainView></ConferenceMainView></template><script>import { ConferenceMainView } from '@tencentcloud/roomkit-web-vue2.7';export default {components: {ConferenceMainView,},};</script>
Step 4: Logging into the TUIRoomKit Component
Before initiating a meeting, it is necessary to invoke the login interface for authentication. To obtain the sdkAppId, userId, and userSig, refer to the service activation.
import { conference } from '@tencentcloud/roomkit-web-vue3';await conference.login({sdkAppId: 0, // Replace with your sdkAppIduserId: '', // Replace with your userIduserSig: '', // Replace with your userSig});
Parameter Explanation:
sdkAppId: Acquired in the final step of service activation.
userId: The current user's ID, a string type, allowing only English letters (a-z, A-Z), numbers (0-9), hyphens (-), and underscores (_).
userSig: Obtained by encrypting information such as
SDKAppID
and UserID
with the SDKSecretKey
retrieved during service activation. UserSig
is an authentication ticket used by Tencent Cloud to verify if the current user can access TRTC services.You can generate a temporarily available UserSig
through the Auxiliary Tool in the console.For more information, refer to the guide on 'How to Calculate and Utilize UserSig.'
Note:
This step is also the step that we have received the most feedback from developers so far. Frequently asked questions are as follows:
The sdkAppId setting is wrong. The SDKAppID of domestic sites is generally a 10-digit integer starting with 140.
UserSig was mismatched to the encryption key (SecretKey). UserSig is obtained by using SecretKey to encrypt information such as SDKAppID, UserID, and expiration time, instead of directly configuring SecretKey to UserSig.
userId is set to simple strings such as "1", "123", "111", etc. Since TRTC does not support multi-terminal login with the same UserID, when multiple people collaborate in development, the form is like "1", "123", "111" "Such a UserID can easily be occupied by your colleagues, causing login failure. Therefore, we recommend that you set some highly identifiable UserIDs during debugging.
The sample code in Github uses the genTestUserSig function to calculate UserSig locally to allow you to run through the current access process faster, but this solution will expose your SecretKey in the code, which is not conducive to your subsequent upgrades and protection. Your SecretKey, so we strongly recommend that you put the calculation logic of UserSig on the server side, and request the real-time calculated UserSig from your server every time you use the TUIRoomKit component.
Step 5: Initiate a new meeting
The conference host can initiate a new conference by calling the start interface. Other participants can refer to the description in step 6 and call the join interface to join the conference.
import { conference } from '@tencentcloud/roomkit-web-vue3';const startConference = async () => {await conference.login({sdkAppId: 0, // Replace with your sdkAppIduserId: '', // Replace with your userIduserSig: '', // Replace with your userSig});await conference.start('123456', {roomName: 'TestRoom',isSeatEnabled: false,isOpenCamera: false,isOpenMicrophone: false,});}startConference()
Step 6: Enter an existing meeting
Participants can join the conference initiated by the conference host in step 5 by calling the join interface and filling in the corresponding roomId parameter.
import { conference } from '@tencentcloud/roomkit-web-vue3';const joinConference = async () => {await conference.login({sdkAppId: 0, // Replace with your sdkAppIduserId: '', // Replace with your userIduserSig: '', // Replace with your userSig});await conference.join('123456', {isOpenCamera: false,isOpenMicrophone: false,});}joinConference()
Development environment running
1. Execute the development environment command. (Here we take the vue3 + vite default project as an example. The dev instructions of different projects may be different. Please adjust according to your own project)
npm run dev
2. According to the console prompts, open the page in the browser, such as: http://localhost:3000/.
3. Experience the TUIRoomKit component functions.
Production environment deployment
1. Package the dist file.
npm run build
2. Deploy the dist file to the server.
Note:
The production environment requires the use of an HTTPS domain name.
Other documents
Communication and feedback
If you have any needs or feedback, you can contact: info_rtc@tencent.com.