|
@@ -1,7 +1,7 @@
|
|
|
import { useState, useEffect, useRef } from 'react';
|
|
import { useState, useEffect, useRef } from 'react';
|
|
|
import { useParams } from 'react-router';
|
|
import { useParams } from 'react-router';
|
|
|
import { User } from '../../../share/types.ts';
|
|
import { User } from '../../../share/types.ts';
|
|
|
-import { TokenAPI } from '../../api.ts';
|
|
|
|
|
|
|
+import { ClassroomAPI } from '../../api/index.ts';
|
|
|
// @ts-types="../../../share/aliyun-rtc-sdk.d.ts"
|
|
// @ts-types="../../../share/aliyun-rtc-sdk.d.ts"
|
|
|
import AliRtcEngine, { AliRtcSubscribeState, AliRtcVideoTrack } from 'aliyun-rtc-sdk';
|
|
import AliRtcEngine, { AliRtcSubscribeState, AliRtcVideoTrack } from 'aliyun-rtc-sdk';
|
|
|
import { toast } from 'react-toastify';
|
|
import { toast } from 'react-toastify';
|
|
@@ -125,7 +125,7 @@ export const useClassroom = ({ user }:{ user : User }) => {
|
|
|
showMessage(`IM断开连接: ${code}`);
|
|
showMessage(`IM断开连接: ${code}`);
|
|
|
// 自动重连
|
|
// 自动重连
|
|
|
try {
|
|
try {
|
|
|
- const { token, nonce, timestamp } = await TokenAPI.getIMToken(userId, role);
|
|
|
|
|
|
|
+ const { token, nonce, timestamp } = await ClassroomAPI.getIMToken(userId, role);
|
|
|
await imEngine.current!.login({
|
|
await imEngine.current!.login({
|
|
|
user: {
|
|
user: {
|
|
|
userId,
|
|
userId,
|
|
@@ -404,7 +404,7 @@ export const useClassroom = ({ user }:{ user : User }) => {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const { ImEngine: ImEngineClass } = window.AliVCInteraction;
|
|
const { ImEngine: ImEngineClass } = window.AliVCInteraction;
|
|
|
- const {appId, appSign, timestamp, nonce, token} = await TokenAPI.getIMToken(userId, role);
|
|
|
|
|
|
|
+ const {appId, appSign, timestamp, nonce, token} = await ClassroomAPI.getIMToken(userId, role);
|
|
|
imEngine.current = ImEngineClass.createEngine();
|
|
imEngine.current = ImEngineClass.createEngine();
|
|
|
await imEngine.current.init({
|
|
await imEngine.current.init({
|
|
|
deviceId: 'xxxx',
|
|
deviceId: 'xxxx',
|
|
@@ -668,7 +668,7 @@ export const useClassroom = ({ user }:{ user : User }) => {
|
|
|
publishScreen = false,
|
|
publishScreen = false,
|
|
|
} = publishOptions || {};
|
|
} = publishOptions || {};
|
|
|
|
|
|
|
|
- const {appId, token, timestamp} = await TokenAPI.getRTCToken(classId, userId);
|
|
|
|
|
|
|
+ const {appId, token, timestamp} = await ClassroomAPI.getRTCToken(classId, userId);
|
|
|
await aliRtcEngine.current.publishLocalVideoStream(publishVideo);
|
|
await aliRtcEngine.current.publishLocalVideoStream(publishVideo);
|
|
|
await aliRtcEngine.current.publishLocalAudioStream(publishAudio);
|
|
await aliRtcEngine.current.publishLocalAudioStream(publishAudio);
|
|
|
await aliRtcEngine.current.publishLocalScreenShareStream(publishScreen);
|
|
await aliRtcEngine.current.publishLocalScreenShareStream(publishScreen);
|