Update src/server.mjs #8

Merged
ztimson merged 1 commits from ztimson-patch-8 into master 2026-09-14 16:27:49 -04:00
+2 -25
View File
@@ -67,36 +67,13 @@ wss.on('connection', ws => {
const socket = net.createConnection(VNC_PORT, VNC_HOST);
socket.on('connect', () => {
console.log(`Connected to VNC ${VNC_HOST}:${VNC_PORT}`);
});
socket.on('data', data => {
console.log(`VNC -> browser: ${data.length} bytes`);
if (data.length <= 64) {
console.log(` hex: ${data.toString('hex')}`);
console.log(` text: ${JSON.stringify(data.toString())}`);
}
if (ws.readyState === ws.OPEN) {
ws.send(data, {binary: true});
}
if (ws.readyState === ws.OPEN) ws.send(data, {binary: true});
});
ws.on('message', (data, isBinary) => {
const buffer = Buffer.isBuffer(data) ? data : Buffer.from(data);
console.log(`Browser -> VNC: ${buffer.length} bytes (${isBinary ? 'binary' : 'text'})`);
if (buffer.length <= 64) {
console.log(` hex: ${buffer.toString('hex')}`);
console.log(` text: ${JSON.stringify(buffer.toString())}`);
}
if (socket.writable) {
socket.write(buffer);
}
if (socket.writable) socket.write(buffer);
});
ws.on('error', error => {