Compare commits

..

No commits in common. "5199f0b764a55bcfec68597ac83768dfa8c7502b" and "55afc59ebc1035672dd89462fb3a8b8bbcbd9c40" have entirely different histories.

4 changed files with 45 additions and 66 deletions

18
main.js
View File

@ -203,7 +203,7 @@ app.on('ready', () => {
break; break;
case 'joinChannel': case 'joinChannel':
// 设置某个人的设备列表 // 设置某个人的设备列表
await connection.invoke(str, data.roomNum, data.enableMicr, data.enableCamera, data.isRoomManager || false) await connection.invoke(str, data.roomNum, data.enableMicr, data.enableCamera)
break; break;
case 'levelChannel': case 'levelChannel':
// 设置某个人的设备列表 // 设置某个人的设备列表
@ -712,14 +712,14 @@ function mainWindowHide() {
} }
const startSignalr = async (user) => { const startSignalr = async (user) => {
connection = new signalR.HubConnectionBuilder() connection = new signalR.HubConnectionBuilder().withAutomaticReconnect()
.withUrl(`${env === 'development' ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc'}/session-manage`, { .withUrl(`${env === 'development' ? 'http://192.168.2.9:5192' : 'https://meeting-api.23544.com/pc'}/session-manage`, {
skipNegotiation: true, skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets, transport: signalR.HttpTransportType.WebSockets,
accessTokenFactory: () => user.token accessTokenFactory: () => user.token
}) })
.withAutomaticReconnect([0, 3000, 3000, 3000])
.build(); .build();
onStart()
mainWindow.webContents.send('changeLocalStorage', { mainWindow.webContents.send('changeLocalStorage', {
isSignalr: true, isSignalr: true,
reconnect: true, reconnect: true,
@ -735,21 +735,13 @@ const startSignalr = async (user) => {
reconnect: false, reconnect: false,
}); });
}); });
connection.start();
} }
const onStart = async () => { const onStart = async () => {
if (connection) { if (connection) {
if (connection.state === signalR.HubConnectionState.Disconnected) {
connection.start().then(() => {
mainWindow.webContents.send('changeLocalStorage', {
reconnect: true,
});
}).catch((err) => {
});
}
if (connection.state !== signalR.HubConnectionState.Connected) { if (connection.state !== signalR.HubConnectionState.Connected) {
connection.start();
} else {
setTimeout(onStart, 3000); setTimeout(onStart, 3000);
} }
} }

View File

@ -423,7 +423,7 @@ const User: React.FC = () => {
if (!addUserFrom.UserName && isCreateUser !== 'batch') { if (!addUserFrom.UserName && isCreateUser !== 'batch') {
return message.error('请输入用户名称!') return message.error('请输入用户名称!')
} }
if (addUserFrom.year === '') { if (!addUserFrom.year) {
return message.error('请输入届!') return message.error('请输入届!')
} }
if (isCreateUser === 'add') { if (isCreateUser === 'add') {

View File

@ -166,7 +166,7 @@ const Meeting: React.FC = () => {
const [currentLookUserAccount, setCurrentLookUserAccount] = useState<any>('') const [currentLookUserAccount, setCurrentLookUserAccount] = useState<any>('')
const [recorder, setRecorder] = useState<any>('') const [recorder, setRecorder] = useState<any>('')
const [_currentRequestSpeakType, setCurrentRequestSpeakType] = useState<'video' | 'audio' | ''>('') const [_currentRequestSpeakType, setCurrentRequestSpeakType] = useState<'video' | 'audio' | ''>('')
const [_mediaStream, setMediaStream] = useState<any>([]) const [_mediaStream, setMediaStream] = useState<any>('')
const [isShare, setIsShare] = useState<any>(null) const [isShare, setIsShare] = useState<any>(null)
const [isSharePopConfirm, setIsSharePopConfirm] = useState(false) const [isSharePopConfirm, setIsSharePopConfirm] = useState(false)
const [_isNetworkDisconnected, setIsNetworkDisconnected] = useState(false) const [_isNetworkDisconnected, setIsNetworkDisconnected] = useState(false)
@ -191,7 +191,6 @@ const Meeting: React.FC = () => {
let userInfo = JSON.parse(storage.getItem('user') as string) let userInfo = JSON.parse(storage.getItem('user') as string)
const msgTips = '您不是管理员或发言人,无法开启此功能!' const msgTips = '您不是管理员或发言人,无法开启此功能!'
const channel = new BroadcastChannel('meeting_channel'); const channel = new BroadcastChannel('meeting_channel');
let storeDevice: any;
useEffect(() => { useEffect(() => {
let time: NodeJS.Timeout; let time: NodeJS.Timeout;
setUser(userInfo) setUser(userInfo)
@ -842,7 +841,7 @@ const Meeting: React.FC = () => {
const mp4Path = `${setting.recordingFilesPath}会议录制_${state.roomName}_${state.channelId}_${dayjs().format('YYYY年MM月DD日HH时mm分')}.webm`; const mp4Path = `${setting.recordingFilesPath}会议录制_${state.roomName}_${state.channelId}_${dayjs().format('YYYY年MM月DD日HH时mm分')}.webm`;
await fs.writeFile(mp4Path, buffer, {}); await fs.writeFile(mp4Path, buffer, {});
setRecorder('') setRecorder('')
setMediaStream([]) setMediaStream('')
confirm({ confirm({
title: '提示', title: '提示',
icon: <ExclamationCircleFilled />, icon: <ExclamationCircleFilled />,
@ -975,6 +974,12 @@ const Meeting: React.FC = () => {
view: null, view: null,
channelId: connection.channelId, channelId: connection.channelId,
}); });
setCurrentVideoId((res: any) => {
if (Number(res) === remoteUid) {
getShowUser();
}
return res
})
} }
}, },
onAudioVolumeIndication: async (speakers: AudioVolumeInfo[]) => { onAudioVolumeIndication: async (speakers: AudioVolumeInfo[]) => {
@ -1031,24 +1036,22 @@ const Meeting: React.FC = () => {
onRtcStats: async (stats: RtcStats) => { onRtcStats: async (stats: RtcStats) => {
setNetworkOther(stats) setNetworkOther(stats)
}, },
onConnectionStateChanged: async (_connection: RtcConnection, state: ConnectionStateType, reason: ConnectionChangedReasonType) => { onConnectionStateChanged: async (_connection: RtcConnection, stateNumber: ConnectionStateType, reason: ConnectionChangedReasonType) => {
const reconnectingCode = [2, 16, 11, 13, 14, 12] const reconnectingCode = [2, 16, 11, 13, 14, 12]
if (state === 4 && reconnectingCode.indexOf(reason) >= 0) { if (stateNumber === 4 && reconnectingCode.indexOf(reason) >= 0) {
message.error('网络断开,请检查网络')
} else if (state === 3) { meetingDisconnectedRef.current.changeModal(true)
setIsScreenCapture(bool => {
if (bool) {
setIsNetworkDisconnected(true)
stopScreenCapture()
}
return bool
})
} else if (stateNumber === 3) {
meetingDisconnectedRef.current.changeModal(false) meetingDisconnectedRef.current.changeModal(false)
} }
}, },
onConnectionLost: () => {
meetingDisconnectedRef.current.changeModal(true)
setIsScreenCapture(bool => {
if (bool) {
setIsNetworkDisconnected(true)
stopScreenCapture()
}
return bool
})
},
onLocalVideoStateChanged: async (_source: VideoSourceType, _state: LocalVideoStreamState, reason: LocalVideoStreamReason) => { onLocalVideoStateChanged: async (_source: VideoSourceType, _state: LocalVideoStreamState, reason: LocalVideoStreamReason) => {
if (reason === 12) { if (reason === 12) {
setIsScreenCapture(bool => { setIsScreenCapture(bool => {
@ -1211,12 +1214,6 @@ const Meeting: React.FC = () => {
} }
return res return res
}) })
setCurrentVideoId((res: any) => {
if (Number(res) === Number(item.uid)) {
getShowUser();
}
return res
})
break; break;
case 'OperAllMicr': case 'OperAllMicr':
setRoomUserList((res: any) => { setRoomUserList((res: any) => {
@ -1492,7 +1489,7 @@ const Meeting: React.FC = () => {
// 录制所有音频输入设备 // 录制所有音频输入设备
audioInputDevices.forEach(async device => { audioInputDevices.forEach(async device => {
const micStream = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: device.deviceId } } }); const micStream = await navigator.mediaDevices.getUserMedia({ audio: { deviceId: { exact: device.deviceId } } });
setMediaStream((res: any) => [...res, micStream]); setMediaStream(micStream);
const micSoundSource = audioCtx.createMediaStreamSource(micStream); const micSoundSource = audioCtx.createMediaStreamSource(micStream);
micSoundSource.connect(systemSoundDestination); micSoundSource.connect(systemSoundDestination);
}) })
@ -1560,11 +1557,9 @@ const Meeting: React.FC = () => {
return res return res
}) })
setMediaStream((res: any) => { setMediaStream((res: any) => {
if (res.length) { if (res) {
res.forEach((item: any) => { res.getTracks().forEach((track: any) => {
item.getTracks().forEach((track: any) => { track.stop()
track.stop()
});
}); });
} }
return res return res
@ -1735,21 +1730,21 @@ const Meeting: React.FC = () => {
break; break;
case 'reconnect': case 'reconnect':
if (e.value == true) { if (e.value == true) {
await window.electron.onInvoke('joinChannel', {
roomNum: state.channelId,
enableMicr: !footerList[0][0].active,
enableCamera: !footerList[0][1].active
})
message.success('网络已连接。') message.success('网络已连接。')
meetingDisconnectedRef.current.changeModal(false) meetingDisconnectedRef.current.changeModal(false)
async function setUserStatus(res: any) { setRoomUserList((res: any) => {
let userItem = res.find((item: any) => item.uid === userInfo.uid) let userItem = res.find((item: any) => item.uid === userInfo.uid)
await window.electron.onInvoke('joinChannel', {
roomNum: state.channelId,
enableMicr: !storeDevice[0][0].active,
enableCamera: !storeDevice[0][1].active,
isRoomManager: userItem.isRoomManager
})
await getRoomUser()
await getShowUser()
if (userItem.isRoomManager) { if (userItem.isRoomManager) {
await postOpenMicr(!storeDevice[0][0].active, userInfo.uid) DeleteRoomManager({
await postOpenCamera(!storeDevice[0][1].active, userInfo.uid) roomId: state.roomId,
roomNum: state.channelId,
userId: userInfo.uid
})
} }
setIsNetworkDisconnected(bool => { setIsNetworkDisconnected(bool => {
if (bool) { if (bool) {
@ -1759,17 +1754,13 @@ const Meeting: React.FC = () => {
}) })
setIsScreenCapture(bool => { setIsScreenCapture(bool => {
if (bool) { if (bool) {
allUserLook(userItem.screenShareId, userItem.userName) allUserLook(userItem.uid, userItem.userName)
} }
return bool return bool
}) })
}
setRoomUserList((res: any) => {
setUserStatus(res)
return res return res
}) })
} else {
storeDevice = JSON.parse(JSON.stringify(footerList))
} }
break; break;
} }
@ -2934,7 +2925,7 @@ const networkIcon = (network: number) => {
switch (network) { switch (network) {
case 0: case 0:
return <svg width="16" height="16" viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg"> return <svg width="16" height="16" viewBox="0 0 33 33" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clipPath="url(#clip0_5499_5160)"> <g clip-path="url(#clip0_5499_5160)">
<path d="M2.01914 32.4824C0.969141 32.4824 0.119141 31.6324 0.119141 30.5824V22.9824C0.119141 21.9324 0.969141 21.0824 2.01914 21.0824C3.06914 21.0824 3.91914 21.9324 3.91914 22.9824V30.5824C3.91914 31.6324 3.06914 32.4824 2.01914 32.4824ZM11.4191 32.4824C10.3691 32.4824 9.51914 31.6324 9.51914 30.5824V15.7824C9.51914 14.7324 10.3691 13.8824 11.4191 13.8824C12.4691 13.8824 13.3191 14.7324 13.3191 15.7824V30.5824C13.3191 31.6324 12.4691 32.4824 11.4191 32.4824ZM20.8191 32.4824C19.7691 32.4824 18.9191 31.6324 18.9191 30.5824V9.38242C18.9191 8.33242 19.7691 7.48242 20.8191 7.48242C21.8691 7.48242 22.7191 8.33242 22.7191 9.38242V30.5824C22.7191 31.6324 21.8691 32.4824 20.8191 32.4824ZM30.2191 32.4824C29.1691 32.4824 28.3191 31.6324 28.3191 30.5824V2.38242C28.3191 1.33242 29.1691 0.482422 30.2191 0.482422C31.2691 0.482422 32.1191 1.33242 32.1191 2.38242V30.5824C32.1191 31.6324 31.2691 32.4824 30.2191 32.4824Z" fill="#7C8280" /> <path d="M2.01914 32.4824C0.969141 32.4824 0.119141 31.6324 0.119141 30.5824V22.9824C0.119141 21.9324 0.969141 21.0824 2.01914 21.0824C3.06914 21.0824 3.91914 21.9324 3.91914 22.9824V30.5824C3.91914 31.6324 3.06914 32.4824 2.01914 32.4824ZM11.4191 32.4824C10.3691 32.4824 9.51914 31.6324 9.51914 30.5824V15.7824C9.51914 14.7324 10.3691 13.8824 11.4191 13.8824C12.4691 13.8824 13.3191 14.7324 13.3191 15.7824V30.5824C13.3191 31.6324 12.4691 32.4824 11.4191 32.4824ZM20.8191 32.4824C19.7691 32.4824 18.9191 31.6324 18.9191 30.5824V9.38242C18.9191 8.33242 19.7691 7.48242 20.8191 7.48242C21.8691 7.48242 22.7191 8.33242 22.7191 9.38242V30.5824C22.7191 31.6324 21.8691 32.4824 20.8191 32.4824ZM30.2191 32.4824C29.1691 32.4824 28.3191 31.6324 28.3191 30.5824V2.38242C28.3191 1.33242 29.1691 0.482422 30.2191 0.482422C31.2691 0.482422 32.1191 1.33242 32.1191 2.38242V30.5824C32.1191 31.6324 31.2691 32.4824 30.2191 32.4824Z" fill="#7C8280" />
<path d="M8.98179 2.67253L6.22791 5.42641L3.47403 2.67253C3.11639 2.31489 2.52627 2.31489 2.16863 2.67253C1.81098 3.03018 1.81098 3.62029 2.16863 3.97794L4.9225 6.73182L2.16863 9.48569C1.81098 9.84334 1.81098 10.4335 2.16863 10.7911C2.52627 11.1488 3.11639 11.1488 3.47403 10.7911L6.22791 8.03723L8.98179 10.7911C9.33943 11.1488 9.92955 11.1488 10.2872 10.7911C10.6448 10.4335 10.6448 9.84334 10.2872 9.48569L7.53332 6.73182L10.2872 3.97794C10.6448 3.62029 10.6448 3.03018 10.2872 2.67253C9.92955 2.31489 9.33943 2.31489 8.98179 2.67253Z" fill="#F90000" /> <path d="M8.98179 2.67253L6.22791 5.42641L3.47403 2.67253C3.11639 2.31489 2.52627 2.31489 2.16863 2.67253C1.81098 3.03018 1.81098 3.62029 2.16863 3.97794L4.9225 6.73182L2.16863 9.48569C1.81098 9.84334 1.81098 10.4335 2.16863 10.7911C2.52627 11.1488 3.11639 11.1488 3.47403 10.7911L6.22791 8.03723L8.98179 10.7911C9.33943 11.1488 9.92955 11.1488 10.2872 10.7911C10.6448 10.4335 10.6448 9.84334 10.2872 9.48569L7.53332 6.73182L10.2872 3.97794C10.6448 3.62029 10.6448 3.03018 10.2872 2.67253C9.92955 2.31489 9.33943 2.31489 8.98179 2.67253Z" fill="#F90000" />
</g> </g>

View File

@ -150,7 +150,7 @@ export const agora = {
}, 1000); }, 1000);
}, },
// 事件回调 // 事件回调
registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication, onNetworkQuality, onRtcStats, onConnectionStateChanged, onLocalVideoStateChanged, onConnectionLost }: any) => { registerEventHandler: ({ onJoinChannelSuccess, onUserJoined, onUserOffline, onAudioVolumeIndication, onNetworkQuality, onRtcStats, onConnectionStateChanged, onLocalVideoStateChanged }: any) => {
rtcEngine.registerEventHandler({ rtcEngine.registerEventHandler({
// 监听本地用户加入频道事件 // 监听本地用户加入频道事件
onJoinChannelSuccess: async (connection: RtcConnection, elapsed: number) => { onJoinChannelSuccess: async (connection: RtcConnection, elapsed: number) => {
@ -196,10 +196,6 @@ export const agora = {
onLocalVideoStateChanged: async (source: VideoSourceType, state: LocalVideoStreamState, reason: LocalVideoStreamReason) => { onLocalVideoStateChanged: async (source: VideoSourceType, state: LocalVideoStreamState, reason: LocalVideoStreamReason) => {
await onLocalVideoStateChanged?.(source, state, reason) await onLocalVideoStateChanged?.(source, state, reason)
}, },
// 网络连接中断,且 SDK 无法在 10 秒内连接服务器回调。
onConnectionLost: (_connection: RtcConnection) => {
onConnectionLost?.()
}
}); });
}, },
// 获取视图模式 // 获取视图模式