Update server.js
Browse files
server.js
CHANGED
|
@@ -15,8 +15,11 @@ wss.on('connection', (ws) => {
|
|
| 15 |
ws.on('message', (message) => {
|
| 16 |
console.log(`Received message: ${message}`);
|
| 17 |
|
|
|
|
|
|
|
|
|
|
| 18 |
// Execute the command received from the client
|
| 19 |
-
exec(
|
| 20 |
if (error) {
|
| 21 |
ws.send(`Error: ${error.message}`);
|
| 22 |
return;
|
|
|
|
| 15 |
ws.on('message', (message) => {
|
| 16 |
console.log(`Received message: ${message}`);
|
| 17 |
|
| 18 |
+
// Convert message (Buffer) to string
|
| 19 |
+
const command = message.toString();
|
| 20 |
+
|
| 21 |
// Execute the command received from the client
|
| 22 |
+
exec(command, (error, stdout, stderr) => {
|
| 23 |
if (error) {
|
| 24 |
ws.send(`Error: ${error.message}`);
|
| 25 |
return;
|