fucking shitass script doesnt even work fuck you
This commit is contained in:
parent
762dc688e8
commit
0f45c368e7
3 changed files with 49 additions and 0 deletions
11
index.js
Normal file
11
index.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import * as server from './server.js';
|
||||
|
||||
console.log(server)
|
||||
server.default(
|
||||
(res) => {
|
||||
console.log(`callback: ${res}`);
|
||||
},
|
||||
(res) => {
|
||||
console.log(`error callback: ${res}`);
|
||||
}
|
||||
);
|
17
package.json
Normal file
17
package.json
Normal file
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"type": "module",
|
||||
"name": "leds",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git@ssh.gitdab.com:jane/leds"
|
||||
},
|
||||
"author": "jane@j4.pm",
|
||||
"license": "UNLICENSED"
|
||||
}
|
21
server.js
Normal file
21
server.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
import * as net from 'net';
|
||||
|
||||
const hostname = '0.0.0.0';
|
||||
const port = 29997;
|
||||
|
||||
export default function recv(callback, errorCallback) {
|
||||
let server = new net.Server();
|
||||
server.listen(port, hostname, () => {
|
||||
server.on('connect', ()=>{
|
||||
console.log('connection recieved')
|
||||
})
|
||||
server.on('data', (data) => {
|
||||
callback(data)
|
||||
})
|
||||
});
|
||||
|
||||
server.on('error', (e) => {
|
||||
server.close();
|
||||
errorCallback(e);
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue