|
@@ -0,0 +1,63 @@
|
|
|
|
|
+import { TUICallKit, VideoDisplayMode, VideoResolution, TUICallKitServer, TUICallType } from "@tencentcloud/call-uikit-react";
|
|
|
|
|
+import { useState } from 'react';
|
|
|
|
|
+// import * as GenerateTestUserSig from "../../../debug/GenerateTestUserSig-es"; // Refer to Step 3
|
|
|
|
|
+import * as GenerateTestUserSig from "../../debug/GenerateTestUserSig-es.js"; // Refer to Step 3
|
|
|
|
|
+<TUICallKit
|
|
|
|
|
+ videoDisplayMode={VideoDisplayMode.CONTAIN}
|
|
|
|
|
+ videoResolution={VideoResolution.RESOLUTION_1080P}
|
|
|
|
|
+ beforeCalling={handleBeforeCalling}
|
|
|
|
|
+ afterCalling={handleAfterCalling}
|
|
|
|
|
+/>
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+function handleBeforeCalling(type: string, error: any) {
|
|
|
|
|
+ console.log("[TUICallkit Demo] handleBeforeCalling:", type, error);
|
|
|
|
|
+}
|
|
|
|
|
+function handleAfterCalling() {
|
|
|
|
|
+ console.log("[TUICallkit Demo] handleAfterCalling");
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+export default function ServiceGuide() {
|
|
|
|
|
+ const SDKAppID = 1600070519; // TODO: Replace with your SDKAppID (Notice: SDKAppID is of type number)
|
|
|
|
|
+ const SDKSecretKey = 'c3100b8b932a1ffed2e2ab8172db85e5f8ed2577a015747b333759a1117af4df'; // TODO: Replace with your SDKSecretKey
|
|
|
|
|
+
|
|
|
|
|
+ const [callerUserID, setCallerUserID] = useState('');
|
|
|
|
|
+ const [calleeUserID, setCalleeUserID] = useState('');
|
|
|
|
|
+
|
|
|
|
|
+ //【2】Initialize the TUICallKit component
|
|
|
|
|
+ const init = async () => {
|
|
|
|
|
+ const { userSig } = GenerateTestUserSig.genTestUserSig({
|
|
|
|
|
+ userID: callerUserID,
|
|
|
|
|
+ SDKAppID,
|
|
|
|
|
+ SecretKey: SDKSecretKey,
|
|
|
|
|
+ });
|
|
|
|
|
+ await TUICallKitServer.init({
|
|
|
|
|
+ userID: callerUserID,
|
|
|
|
|
+ userSig,
|
|
|
|
|
+ SDKAppID,
|
|
|
|
|
+ });
|
|
|
|
|
+ alert('TUICallKit init succeed');
|
|
|
|
|
+ }
|
|
|
|
|
+ //【3】Make a 1v1 video call
|
|
|
|
|
+ const call = async () => {
|
|
|
|
|
+ await TUICallKitServer.call({
|
|
|
|
|
+ userID: calleeUserID,
|
|
|
|
|
+ type: TUICallType.AUDIO_CALL,
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+ return (
|
|
|
|
|
+ <>
|
|
|
|
|
+ <span> 输入登录ID: </span>
|
|
|
|
|
+ <input type="text" placeholder='input caller userID' value={callerUserID} onChange={(event) => setCallerUserID(event.target.value)} />
|
|
|
|
|
+ <button onClick={init}> 用户1. 登录 </button> <br />
|
|
|
|
|
+ <span> 输入呼叫ID: </span>
|
|
|
|
|
+ <input type="text" placeholder='input callee userID' value={calleeUserID} onChange={(event) => setCalleeUserID(event.target.value)} />
|
|
|
|
|
+ <button onClick={call}> 用户2. 呼叫 </button>
|
|
|
|
|
+
|
|
|
|
|
+ {/* 【1】Import the TUICallKit component: Call interface UI */}
|
|
|
|
|
+ <TUICallKit />
|
|
|
|
|
+ </>
|
|
|
|
|
+ );
|
|
|
|
|
+}
|