generated from marlon360/aframe-webpack-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathserver-ssl.js
31 lines (26 loc) · 764 Bytes
/
server-ssl.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
30
31
const express = require('express');
const port = process.env.PORT || 3000
const app = express();
const fs = require('fs');
const http = require('https').createServer({
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem'),
passphrase: 'marlon'
}, app);
const io = require('socket.io')(http);
app.use(express.static('dist'));
app.get('/', (req, res) => {
res.render('index.html');
});
io.on('connection', (socket) => {
console.log('a user connected');
socket.on('draw', function (obj) {
io.emit('remoteDraw', obj, { for: 'everyone' });
});
socket.on('eraseAll', function (obj) {
io.emit('remoteEraseAll', obj, { for: 'everyone' });
});
});
http.listen(port, () => {
console.log('server running at :3000');
});