ws server

This commit is contained in:
ntr 2018-08-27 22:37:35 +10:00
parent cb369e4683
commit 475b0c02c9
7 changed files with 61 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,3 +0,0 @@
cryps-rs/target/
cryps-rs/**/*.rs.bk
cryps-rs/Cargo.lock

1
api/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/

2
api/index.js Executable file
View File

@ -0,0 +1,2 @@
const createServer = require('./src/server');
createServer();

21
api/package-lock.json generated Normal file
View File

@ -0,0 +1,21 @@
{
"name": "cryps-api",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"async-limiter": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz",
"integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg=="
},
"ws": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz",
"integrity": "sha512-c2UlYcAZp1VS8AORtpq6y4RJIkJ9dQz18W32SpR/qXGfLDZ2jU4y4wKvvZwqbi7U6gxFQTeE+urMbXU/tsDy4w==",
"requires": {
"async-limiter": "~1.0.0"
}
}
}
}

15
api/package.json Executable file
View File

@ -0,0 +1,15 @@
{
"name": "cryps-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"ws": "^6.0.0"
}
}

19
api/src/server.js Executable file
View File

@ -0,0 +1,19 @@
const WebSocket = require('ws');
function createServer() {
const wss = new WebSocket.Server({ port: 40080 });
console.log('i am listening...');
wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
});
ws.send('sup');
});
return wss;
}
module.exports = createServer;

3
cryps-rs/.gitignore vendored Executable file
View File

@ -0,0 +1,3 @@
target/
**/*.rs.bk
Cargo.lock