123
This commit is contained in:
@@ -222,8 +222,13 @@ async def chat(websocket: WebSocket):
|
||||
continue
|
||||
print(f"----------------{message.source}----------------\n {message.content}")
|
||||
if message.type == 'TextMessage' or message.type == 'HandoffMessage' \
|
||||
or message.type == 'ToolCallRequestEvent' or message.type == 'UserInputRequestedEvent':
|
||||
await websocket.send_json(message.model_dump())
|
||||
or message.type == 'UserInputRequestedEvent':
|
||||
if isinstance(message.content, str):
|
||||
await websocket.send_json(message.model_dump())
|
||||
else:
|
||||
_message = message
|
||||
_message.content = str(_message.content)
|
||||
await websocket.send_json(_message.model_dump())
|
||||
if not isinstance(message, UserInputRequestedEvent):
|
||||
history.append(message.model_dump())
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, onUnmounted, defineExpose, defineEmits, watch } from 'vue'
|
||||
import { ref, onMounted, onUnmounted, defineExpose, defineEmits, watch} from 'vue'
|
||||
import useWebSocket from '../../utils/websocket'
|
||||
// const cameraOne = ref("")
|
||||
// const cameraTwo = ref("");
|
||||
@@ -48,57 +48,44 @@ const handleTwoMessage = (e: any) => {
|
||||
}
|
||||
}
|
||||
const cameraNumber = ref<Number>(0)
|
||||
const wsOne = ref<any>(null)
|
||||
const wsTwo = ref<any>(null)
|
||||
|
||||
watch(cameraNumber,(newVal,oldVal)=>{
|
||||
if (oldVal === 1 && wsOne.value) {
|
||||
wsOne.value.handleClose()
|
||||
wsOne.value = null
|
||||
} else if (oldVal === 2 && wsTwo.value) {
|
||||
wsTwo.value.handleClose()
|
||||
wsTwo.value = null
|
||||
}
|
||||
|
||||
if (newVal === 1) {
|
||||
wsOne.value = useWebSocket(handleMessage, import.meta.env.VITE_WB_CAMERA_ONE_URL)
|
||||
} else if (newVal === 2) {
|
||||
wsTwo.value = useWebSocket(handleTwoMessage, import.meta.env.VITE_WB_CAMERA_TWO_URL)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
onMounted(() => {})
|
||||
const emit = defineEmits(['closeCamera'])
|
||||
|
||||
const closeCamera = () => {
|
||||
cameraNumber.value = 0
|
||||
emit('closeCamera')
|
||||
|
||||
// 关闭所有连接
|
||||
if (wsOne.value) {
|
||||
console.log(wsOne.value)
|
||||
wsOne.value.handleClose()
|
||||
wsOne.value = null
|
||||
}
|
||||
if (wsTwo.value) {
|
||||
wsTwo.value.handleClose()
|
||||
wsTwo.value = null
|
||||
}
|
||||
}
|
||||
|
||||
const ws = ref<any>(null) // WebSocket instance for camera 1
|
||||
const wsTwo = ref<any>(null) // WebSocket instance for camera 2
|
||||
// const ws: any = useWebSocket(handleMessage, import.meta.env.VITE_WB_CAMERA_ONE_URL)
|
||||
// const wsTwo: any = useWebSocket(
|
||||
// handleTwoMessage,
|
||||
// import.meta.env.VITE_WB_CAMERA_TWO_URL
|
||||
// )
|
||||
|
||||
const emit = defineEmits(['closeCamera'])
|
||||
// const ws = new WebSocket(import.meta.env.VITE_WB_CAMERA_ONE_URL)
|
||||
|
||||
// const closeCamera = () => {
|
||||
// cameraNumber.value = 0
|
||||
// emit('closeCamera')
|
||||
// }
|
||||
|
||||
const stopWebSocket = () =>{
|
||||
// Close WebSocket connections
|
||||
if (ws.value) {
|
||||
ws.value.close()
|
||||
ws.value = null
|
||||
}
|
||||
if (wsTwo.value) {
|
||||
wsTwo.value.close()
|
||||
wsTwo.value = null
|
||||
}
|
||||
}
|
||||
const closeCamera = () => {
|
||||
// Reset the camera number
|
||||
cameraNumber.value = 0
|
||||
stopWebSocket() // Stop any active WebSocket connection
|
||||
emit('closeCamera')
|
||||
}
|
||||
watch(cameraNumber, (newVal) => {
|
||||
stopWebSocket()
|
||||
|
||||
if(newVal == 1){
|
||||
ws.value = useWebSocket(handleMessage, import.meta.env.VITE_WB_CAMERA_ONE_URL)
|
||||
}else if(newVal == 2){
|
||||
wsTwo.value = useWebSocket(handleTwoMessage, import.meta.env.VITE_WB_CAMERA_TWO_URL)
|
||||
}
|
||||
})
|
||||
// })
|
||||
// const closeWs = () => {
|
||||
// if (ws) {
|
||||
// ws.handleClose()
|
||||
@@ -109,11 +96,14 @@ const closeCamera = () => {
|
||||
// wsTwo.handleClose()
|
||||
// }
|
||||
// }
|
||||
// onMounted(() => {})
|
||||
|
||||
onUnmounted(() => {
|
||||
stopWebSocket()
|
||||
})
|
||||
|
||||
defineExpose({ cameraNumber })
|
||||
// onUnmounted(() => {
|
||||
// closeWs()
|
||||
// closeWsTwo()
|
||||
// })
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@@ -93,8 +93,6 @@ const cameraFun = (val: number) => {
|
||||
}
|
||||
const closeCamera = () => {
|
||||
cameraShow.value = false
|
||||
console.log(cameraShow.value);
|
||||
// cameraViewRef.value.cameraNumber = 0
|
||||
}
|
||||
const reasoningList = ref<Array<any>>([])
|
||||
// const getModelListFun = async () => {
|
||||
|
||||
Reference in New Issue
Block a user