mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
try to manage session
This commit is contained in:
1 parent
7fa5ab5bc6
commit
9b5b5571ef
1 file changed
+25
-2
@@ -14,6 +14,7 @@ import { FitAddon } from 'xterm-addon-fit'
|
|||||||
import 'xterm/css/xterm.css'
|
import 'xterm/css/xterm.css'
|
||||||
import { io } from 'socket.io-client'
|
import { io } from 'socket.io-client'
|
||||||
import { onMounted, ref } from 'vue'
|
import { onMounted, ref } from 'vue'
|
||||||
|
import api from '../utils/api'
|
||||||
|
|
||||||
const rows = ref(40)
|
const rows = ref(40)
|
||||||
const cols = ref(100)
|
const cols = ref(100)
|
||||||
@@ -37,13 +38,14 @@ onMounted(() => {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
const host = 'wss://odyssey.wancat.cc'
|
const host = 'wss://odyssey.wancat.cc'
|
||||||
|
const sessionhost = 'http://odyssey.wancat.cc'
|
||||||
// const host = 'ws://localhost:3000'
|
// const host = 'ws://localhost:3000'
|
||||||
const socket = io(host, {
|
const socket = io(host, {
|
||||||
query: {
|
query: {
|
||||||
// session_id: sessionId,
|
// session_id: sessionId,
|
||||||
session_id: '64d26a8cffab987b2bb0de38',
|
// session_id: '64d26a8cffab987b2bb0de38',
|
||||||
// odyssey
|
// odyssey
|
||||||
// session_id: '64d271ce784daf755387ff4f',
|
session_id: '64d271ce784daf755387ff4f',
|
||||||
// localhost
|
// localhost
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -56,6 +58,27 @@ onMounted(() => {
|
|||||||
socket.on('message', (message) => {
|
socket.on('message', (message) => {
|
||||||
console.log(message)
|
console.log(message)
|
||||||
term.write(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) => {
|
term.onData((key) => {
|
||||||
console.log(key)
|
console.log(key)
|
||||||
|
|||||||
Reference in new issue
Block a user