From a407bf15f72e68467dc01c90069c5c2ae7f958b0 Mon Sep 17 00:00:00 2001 From: LukeGus Date: Wed, 4 Dec 2024 21:53:21 -0600 Subject: [PATCH] Nano and timeout error fix #7 (plus css changes for hide buttons) --- backend/server.js | 21 ++++++++++++++++++--- frontend/src/App.css | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/server.js b/backend/server.js index 0b85a9a0..a7c83c6b 100644 --- a/backend/server.js +++ b/backend/server.js @@ -59,9 +59,24 @@ wss.on('connection', (ws) => { // Forward user input and resize events to the SSH stream ws.on('message', (message) => { - console.log('User Input:', message); - stream.write(message); - }); + let data; + + // Try parsing the message as JSON + try { + data = JSON.parse(message); + } catch (err) { + // If it's not JSON, it's likely user input. Forward it to the SSH stream. + console.log('User Input:', message); + stream.write(message); + return; // Exit early since it's user input + } + + // If it's a resize event, handle it + if (data.type === 'resize' && data.rows && data.cols) { + console.log('Resize event received:', data); + stream.setWindow(data.rows, data.cols, data.height, data.width); + } + }); }); }) .on('error', (err) => { diff --git a/frontend/src/App.css b/frontend/src/App.css index fe359acc..e79169c5 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -63,7 +63,7 @@ .hide-sidebar-button { position: fixed; bottom: 10px; - right: 10px; + right: 13px; background-color: rgb(108, 108, 108); color: white; border: none;