Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require('fs');
- const https = require('https');
- const WebSocket = require('ws');
- const server = new https.createServer({
- key: file.readFileSync('/etc/letsencrypt/live/[...]/privkey.pem'),
- cert: file.readFileSync('/etc/letsencrypt/live/[...]/cert.pem')
- });
- const wss = new WebSocket.Server({ server });
- wss.on('connection', openConnection);
- function openConnection (ws) {
- ws.on('message', function incoming(message) {
- console.log('received: %s', message);
- });
- ws.send('something');
- }
- server.listen(8443);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement