mirror of
https://github.com/syssecfsu/witty.git
synced 2025-01-11 20:52:43 +01:00
fix minor issues
This commit is contained in:
parent
b4b1fb6139
commit
e9241e7a6e
@ -38,11 +38,11 @@
|
|||||||
term = createTerminal("{{.path}}");
|
term = createTerminal("{{.path}}");
|
||||||
// print something to test output and scroll
|
// print something to test output and scroll
|
||||||
var str = [
|
var str = [
|
||||||
' ┌────────────────────────────────────────────────────────────────────────────┐',
|
' ┌────────────────────────────────────────────────────────────────────────────┐\n',
|
||||||
' │ Powered by \u001b[32;1mGo, Gin, websocket, pty, and https://xtermjs.org\x1b[0m │',
|
' │ Powered by \u001b[32;1mGo, Gin, websocket, pty, and https://xtermjs.org\x1b[0m │\n',
|
||||||
' └────────────────────────────────────────────────────────────────────────────┘',
|
' └────────────────────────────────────────────────────────────────────────────┘\n',
|
||||||
''
|
''
|
||||||
].join('\n\r');
|
].join('');
|
||||||
|
|
||||||
term.writeln(str);
|
term.writeln(str);
|
||||||
</script>
|
</script>
|
||||||
|
@ -189,7 +189,7 @@ func (tc *TermConn) ptyStdoutToWs(wg *sync.WaitGroup) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
readBuf = readBuf[:n] // slice the buffer so that it is exact the size of data read.
|
readBuf = readBuf[0:n] // slice the buffer so that it is exact the size of data read.
|
||||||
bufChan <- readBuf
|
bufChan <- readBuf
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -209,7 +209,7 @@ out:
|
|||||||
// We could add ws to viewers as well (then we can use io.MultiWriter),
|
// We could add ws to viewers as well (then we can use io.MultiWriter),
|
||||||
// but we want to handle errors differently
|
// but we want to handle errors differently
|
||||||
tc.ws.SetWriteDeadline(time.Now().Add(writeWait))
|
tc.ws.SetWriteDeadline(time.Now().Add(writeWait))
|
||||||
if err := tc.ws.WriteMessage(websocket.BinaryMessage, buf); err != nil {
|
if err := tc.ws.WriteMessage(websocket.TextMessage, buf); err != nil {
|
||||||
log.Println("Failed to write message: ", err)
|
log.Println("Failed to write message: ", err)
|
||||||
break out
|
break out
|
||||||
}
|
}
|
||||||
@ -222,7 +222,7 @@ out:
|
|||||||
|
|
||||||
// if the viewer exits, we will just ignore the error
|
// if the viewer exits, we will just ignore the error
|
||||||
w.SetWriteDeadline(time.Now().Add(viewWait))
|
w.SetWriteDeadline(time.Now().Add(viewWait))
|
||||||
if err := w.WriteMessage(websocket.BinaryMessage, buf); err != nil {
|
if err := w.WriteMessage(websocket.TextMessage, buf); err != nil {
|
||||||
log.Println("Failed to write message to viewer: ", err)
|
log.Println("Failed to write message to viewer: ", err)
|
||||||
|
|
||||||
viewers[i] = nil
|
viewers[i] = nil
|
||||||
@ -231,7 +231,7 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
case viewer := <-tc.vchan:
|
case viewer := <-tc.vchan:
|
||||||
log.Println("Received viewer", viewer.RemoteAddr().String() )
|
log.Println("Received viewer", viewer.RemoteAddr().String())
|
||||||
viewers = append(viewers, viewer)
|
viewers = append(viewers, viewer)
|
||||||
|
|
||||||
case <-tc.ws_done:
|
case <-tc.ws_done:
|
||||||
|
Loading…
Reference in New Issue
Block a user