mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
refactor: move client to sperate packages, rename cli to container
This commit is contained in:
1 parent
41a12c9aa8
commit
6ace18475b
15 files changed
+51
-28
No files matched your search
@@ -6,7 +6,8 @@ import commandHandler from '../../game/commandHandler.js'
|
||||
|
||||
export async function newCommand(req, res) {
|
||||
console.log('new command:', req.body)
|
||||
const { token, command, pwd, output, error } = req.body
|
||||
const { token, command, pwd, output, error, ...additionalData } = req.body
|
||||
console.log('additionalData:', additionalData)
|
||||
|
||||
if (!command) {
|
||||
res.status(400).json({ message: 'command is required' })
|
||||
|
||||
@@ -50,10 +50,12 @@ export default (server) => {
|
||||
const stream = await attachContainer(container, { token })
|
||||
|
||||
stream.on('data', (chunk) => {
|
||||
socket.send(chunk.toString())
|
||||
socket.emit('terminal', chunk.toString())
|
||||
})
|
||||
|
||||
socket.on('message', function incoming(message) {
|
||||
socket.on('message', console.log)
|
||||
|
||||
socket.on('terminal', function incoming(message) {
|
||||
stream.write(message)
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user