Split input into buffer sized chunks

Input chunks from the client exceeding the buffer size would get
truncated. Now we communicate the size of the buffer to the webtty and
it will split the input into buffer sized chunks.

Fixes #1.
This commit is contained in:
Søren L. Hansen 2021-04-12 19:39:32 -07:00
parent 77c436b99b
commit 0d6766f621
6 changed files with 27 additions and 3 deletions

View file

@ -28,4 +28,6 @@ const (
SetPreferences = '4'
// Make terminal to reconnect
SetReconnect = '5'
// Set the input buffer size
SetBufferSize = '6'
)

View file

@ -115,6 +115,12 @@ func (wt *WebTTY) sendInitializeMessage() error {
return errors.Wrapf(err, "failed to send window title")
}
bufSizeMsg, _ := json.Marshal(wt.bufferSize)
err = wt.masterWrite(append([]byte{SetBufferSize}, bufSizeMsg...))
if err != nil {
return errors.Wrapf(err, "failed to send buffer size")
}
if wt.reconnect > 0 {
reconnect, _ := json.Marshal(wt.reconnect)
err := wt.masterWrite(append([]byte{SetReconnect}, reconnect...))