| | |
| | | |
| | | <script> |
| | | import { getStudentList } from '@/api/meet' |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | }, |
| | | beforeDestroy() { |
| | | if (this.ws) { |
| | | this.ws.close(); |
| | | this.ws.close() |
| | | } |
| | | }, |
| | | methods: { |
| | | muteEveryone() { |
| | | this.jitsiApi.executeCommand('muteEveryone', 'audio'); |
| | | this.jitsiApi.executeCommand('muteEveryone', 'audio') |
| | | }, |
| | | videoEveryone() { |
| | | this.jitsiApi.executeCommand('muteEveryone', 'video'); |
| | | this.jitsiApi.executeCommand('muteEveryone', 'video') |
| | | }, |
| | | handleCommand(command) { |
| | | this.sendMessage(JSON.stringify(command)) |
| | | }, |
| | | initWebSocket() { |
| | | this.ws = new WebSocket('ws://127.0.0.1:8000/websocket/' + 1); |
| | | let ws = this.ws; |
| | | this.ws = new WebSocket('ws://127.0.0.1:8000/websocket/' + 1) |
| | | let ws = this.ws |
| | | ws.onopen = () => { |
| | | console.log('WebSocket 连接成功'); |
| | | console.log('WebSocket 连接成功') |
| | | // 发送心跳数据 |
| | | ws.send('ping'); |
| | | }; |
| | | ws.send('ping') |
| | | } |
| | | ws.onmessage = (event) => { |
| | | console.log('收到服务器消息:', event.data); |
| | | console.log('收到服务器消息:', event.data) |
| | | // 处理服务器发来的消息 |
| | | }; |
| | | } |
| | | ws.onerror = (error) => { |
| | | console.error('WebSocket 连接出错:', error); |
| | | }; |
| | | console.error('WebSocket 连接出错:', error) |
| | | } |
| | | ws.onclose = () => { |
| | | console.log('WebSocket 连接已关闭'); |
| | | console.log('WebSocket 连接已关闭') |
| | | // 可以在这里尝试重新连接 |
| | | }; |
| | | } |
| | | |
| | | // 组件销毁时断开 WebSocket 连接 |
| | | this.$once('hook:beforeDestroy', () => { |
| | | ws.close(); |
| | | }); |
| | | ws.close() |
| | | }) |
| | | }, |
| | | sendMessage(message) { |
| | | if (this.ws.readyState === WebSocket.OPEN) { |
| | | this.ws.send(message); |
| | | this.ws.send(message) |
| | | } else { |
| | | console.error('WebSocket 连接未打开'); |
| | | console.error('WebSocket 连接未打开') |
| | | } |
| | | }, |
| | | hiddenStudent() { |
| | |
| | | 'camera', |
| | | // 聊天 |
| | | 'chat', |
| | | // 'closedcaptions', |
| | | // 共享 |
| | | 'desktop', |
| | | 'download', |
| | | // 'embedmeeting', |
| | | // 'etherpad', |
| | | // 'feedback', |
| | | // 'filmstrip', |
| | | 'fullscreen', |
| | | 'hangup', |
| | | // 'help', |
| | |
| | | 'livestreaming', |
| | | 'microphone', |
| | | 'noisesuppression', |
| | | // 'participants-pane', |
| | | // 'profile', |
| | | // 'raisehand', |
| | | 'recording', |
| | | // 'security', |
| | | 'select-background', |
| | | 'settings', |
| | | 'shareaudio', |
| | |
| | | 'stats', |
| | | 'tileview', |
| | | 'toggle-camera', |
| | | // 'videoquality', |
| | | 'whiteboard' |
| | | 'whiteboard', |
| | | |
| | | // 'closedcaptions', |
| | | // 'embedmeeting', |
| | | // 'etherpad', |
| | | // 'feedback', |
| | | // 'filmstrip', |
| | | 'participants-pane', |
| | | // 'profile', |
| | | 'raisehand', |
| | | // 'security', |
| | | 'videoquality', |
| | | ], |
| | | whiteboard: { |
| | | enabled: true |
| | |
| | | }, 2500) |
| | | |
| | | // 初始化 |
| | | this.initWebSocket(); |
| | | this.initWebSocket() |
| | | }, |
| | | beforeDestroy() { |
| | | // 清除定时器,避免内存泄漏 |