mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
fix: reset terminal on connection and improve error handling
This commit is contained in:
1 parent
c2566cf3dd
commit
aba492ff43
1 file changed
+1
-2
@@ -37,6 +37,7 @@ class SocketTerminal {
|
|||||||
})
|
})
|
||||||
this.socket.onopen = () => {
|
this.socket.onopen = () => {
|
||||||
console.log('Connected to terminal')
|
console.log('Connected to terminal')
|
||||||
|
this.term.reset()
|
||||||
this.term.write('\r\n\x1B[1;32mConnected to terminal\x1B[0m\r\n')
|
this.term.write('\r\n\x1B[1;32mConnected to terminal\x1B[0m\r\n')
|
||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
@@ -44,7 +45,6 @@ class SocketTerminal {
|
|||||||
this.socket.onclose = () => {
|
this.socket.onclose = () => {
|
||||||
console.log('Disconnected from terminal')
|
console.log('Disconnected from terminal')
|
||||||
this.term.write('\r\n\x1B[1;31mDisconnected from terminal\x1B[0m\r\n')
|
this.term.write('\r\n\x1B[1;31mDisconnected from terminal\x1B[0m\r\n')
|
||||||
reject(new Error('Disconnected from terminal'))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.socket.onerror = (error) => {
|
this.socket.onerror = (error) => {
|
||||||
@@ -52,7 +52,6 @@ class SocketTerminal {
|
|||||||
this.term.write(
|
this.term.write(
|
||||||
`\r\n\x1B[1;31mWebSocket error: ${'message' in error ? error.message : ''}\x1B[0m\r\n`
|
`\r\n\x1B[1;31mWebSocket error: ${'message' in error ? error.message : ''}\x1B[0m\r\n`
|
||||||
)
|
)
|
||||||
reject(error)
|
|
||||||
}
|
}
|
||||||
this.socket.onmessage = (event) => {
|
this.socket.onmessage = (event) => {
|
||||||
console.log('Received message from terminal')
|
console.log('Received message from terminal')
|
||||||
|
|||||||
Reference in new issue
Block a user