refactor: move client to sperate packages, rename cli to container

This commit is contained in:
wancat committed 2023-08-21 20:40:05 +08:00
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' })
+4 -2
View File
@@ -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)
})