-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
29 lines (24 loc) · 920 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var fs = require('fs');
var express = require('express');
var app = express();
app.use(express.static('.'));
var privateKey = fs.readFileSync('/etc/letsencrypt/live/buonanno.tech/privkey.pem', 'utf8');
var certificate = fs.readFileSync('/etc/letsencrypt/live/buonanno.tech/fullchain.pem', 'utf8');
var credentials = { key: privateKey, cert: certificate };
var https = require('https').createServer(credentials, app);
var io = require('socket.io')(https);
io.on('connection', function (socket) {
console.log('a user connected: ' + socket.handshake.address);
socket.on('disconnect', function () {
console.log('user disconnected');
});
socket.on("sendDesc", function (msg) {
io.emit("sendDesc", msg);
});
socket.on("recDesc", function (msg) {
io.emit("recDesc", msg);
});
});
https.listen(3000, function () {
console.log('Open https://buonanno.tech:3000 ');
});