mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: socket error handling
* create a new session when failed to connect to socket * reset termnal on connect
This commit is contained in:
1 parent
2639c0ddda
commit
ed14491cfc
4 files changed
+39
-31
No files matched your search
@@ -35,7 +35,7 @@ async function connectClient(socket) {
|
||||
}
|
||||
const sessionId = socket.handshake.query.session_id
|
||||
if (!sessionId) {
|
||||
socket.send('Session ID not found.')
|
||||
socket.emit('error', 'Session ID not found.')
|
||||
socket.disconnect()
|
||||
return
|
||||
}
|
||||
@@ -46,7 +46,7 @@ async function connectClient(socket) {
|
||||
status: 'active',
|
||||
})
|
||||
if (!session) {
|
||||
socket.send('Session not found.')
|
||||
socket.emit('error', 'Session not found.')
|
||||
socket.disconnect()
|
||||
return
|
||||
}
|
||||
@@ -61,7 +61,7 @@ async function connectClient(socket) {
|
||||
container = await getAndStartContainer(session.containerId)
|
||||
stream = await attachContainer(container, { token })
|
||||
} catch (err) {
|
||||
socket.send(err.message)
|
||||
socket.emit('error', 'Failed to start container.')
|
||||
socket.disconnect()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user