mirror of
https://github.com/litruv/DAdmin.git
synced 2026-07-24 02:36:11 +10:00
wss testing
This commit is contained in:
20
package-lock.json
generated
20
package-lock.json
generated
@@ -401,6 +401,17 @@
|
||||
"snekfetch": "^3.6.4",
|
||||
"tweetnacl": "^1.0.0",
|
||||
"ws": "^4.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ws": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
|
||||
"integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
|
||||
"requires": {
|
||||
"async-limiter": "~1.0.0",
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"duplexify": {
|
||||
@@ -1831,12 +1842,11 @@
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
|
||||
},
|
||||
"ws": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
|
||||
"integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
|
||||
"integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
|
||||
"requires": {
|
||||
"async-limiter": "~1.0.0",
|
||||
"safe-buffer": "~5.1.0"
|
||||
"async-limiter": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"xtend": {
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"ping": "^0.2.2",
|
||||
"promise-mysql": "^3.3.1",
|
||||
"readline": "^1.3.0",
|
||||
"request": "^2.88.0"
|
||||
"request": "^2.88.0",
|
||||
"ws": "^6.2.1"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
|
||||
32
plugins/wss.js
Normal file
32
plugins/wss.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const fs = require('fs');
|
||||
const https = require('https');
|
||||
const WebSocket = require('ws');
|
||||
|
||||
const fs = require("fs")
|
||||
|
||||
|
||||
module.exports = {
|
||||
name: "Websockets Server (8080)",
|
||||
init: (dclient) => {
|
||||
client = dclient
|
||||
|
||||
|
||||
const server = https.createServer({
|
||||
cert: fs.readFileSync('./cert.pem'),
|
||||
key: fs.readFileSync('./privkey.pem')
|
||||
});
|
||||
const wss = new WebSocket.Server({ server });
|
||||
|
||||
wss.on('connection', function connection(ws) {
|
||||
ws.on('message', function incoming(message) {
|
||||
console.log('received: %s', message);
|
||||
ws.send(`something ${message}`);
|
||||
});
|
||||
|
||||
ws.send('something');
|
||||
});
|
||||
|
||||
server.listen(8080);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user