mirror of
https://github.com/litruv/DAdmin.git
synced 2026-07-24 02:36:11 +10:00
wss testing
This commit is contained in:
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