Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs');
  2. const https = require('https');
  3. const WebSocket = require('ws');
  4.  
  5. const server = new https.createServer({
  6.   key: file.readFileSync('/etc/letsencrypt/live/[...]/privkey.pem'),
  7.   cert: file.readFileSync('/etc/letsencrypt/live/[...]/cert.pem')
  8. });
  9. const wss = new WebSocket.Server({ server });
  10.  
  11. wss.on('connection', openConnection);
  12.  
  13. function openConnection (ws) {
  14.   ws.on('message', function incoming(message) {
  15.     console.log('received: %s', message);
  16.   });
  17.  
  18.   ws.send('something');
  19. }
  20.  
  21. server.listen(8443);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement