try to manage session

This commit is contained in:
Annie Huang authored and wancat committed 2023-08-17 19:45:20 +08:00
1 parent 7fa5ab5bc6
commit 9b5b5571ef
1 file changed
+25 -2
+25 -2
View File
@@ -14,6 +14,7 @@ import { FitAddon } from 'xterm-addon-fit'
import 'xterm/css/xterm.css'
import { io } from 'socket.io-client'
import { onMounted, ref } from 'vue'
import api from '../utils/api'
const rows = ref(40)
const cols = ref(100)
@@ -37,13 +38,14 @@ onMounted(() => {
},
})
const host = 'wss://odyssey.wancat.cc'
const sessionhost = 'http://odyssey.wancat.cc'
// const host = 'ws://localhost:3000'
const socket = io(host, {
query: {
// session_id: sessionId,
session_id: '64d26a8cffab987b2bb0de38',
// session_id: '64d26a8cffab987b2bb0de38',
// odyssey
// session_id: '64d271ce784daf755387ff4f',
session_id: '64d271ce784daf755387ff4f',
// localhost
},
})
@@ -56,6 +58,27 @@ onMounted(() => {
socket.on('message', (message) => {
console.log(message)
term.write(message)
const session =
// api.get('') ||
// (program.opts().create ? (await createdSession())._id : null) ||
// (await lastSession())._id
// if (message == 'Session not found.') {
// term.write('\nSession undefined')
// console.log('Creating a new session...')
// const res = fetch(`${sessionhost}/api/v1/sessions`, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// questid: 'helloworld',
// }),
// })
// const data = res.json()
console.log(res)
// console.log(data)
// console.log('Created Session ID:', data.id)
}
})
term.onData((key) => {
console.log(key)