Skip to content

Commit

Permalink
Create server(run_on_pc).js
Browse files Browse the repository at this point in the history
  • Loading branch information
a0zhar committed Mar 5, 2023
1 parent 5807d6b commit c61580d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions server(run_on_pc).js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
var sheesh = require('ws');
var fs = require('fs');
var server = new sheesh.Server({ port: 5000 });

server.on('connection', (socket) => {
console.log('Client connected');

socket.on('message', (message) => {
console.log("writing");
const bytes = message.toString().split(',').map(Number);
const text = String.fromCharCode.apply(null, bytes);
// this what i mean by u having to manually change file name
fs.appendFile("name.bin", text, (err) => {
if (err) throw err;
console.log('Data appended to file');
});
});

socket.on('close', () => {
console.log('Client disconnected');
});

});

0 comments on commit c61580d

Please sign in to comment.