ws server
This commit is contained in:
parent
cb369e4683
commit
475b0c02c9
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
cryps-rs/target/
|
||||
cryps-rs/**/*.rs.bk
|
||||
cryps-rs/Cargo.lock
|
||||
1
api/.gitignore
vendored
Normal file
1
api/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
node_modules/
|
||||
2
api/index.js
Executable file
2
api/index.js
Executable file
@ -0,0 +1,2 @@
|
||||
const createServer = require('./src/server');
|
||||
createServer();
|
||||
21
api/package-lock.json
generated
Normal file
21
api/package-lock.json
generated
Normal 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
15
api/package.json
Executable 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
19
api/src/server.js
Executable 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
3
cryps-rs/.gitignore
vendored
Executable file
@ -0,0 +1,3 @@
|
||||
target/
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
Loading…
x
Reference in New Issue
Block a user