-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (21 loc) · 699 Bytes
/
index.js
File metadata and controls
27 lines (21 loc) · 699 Bytes
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
var express = require('express');
var app = express();
var fs = require('fs');
var privateKey = fs.readFileSync('sslcert/key.pem');
var certificate = fs.readFileSync('sslcert/cert.pem');
var httpsServer = require('https').createServer({
key:privateKey,
cert: certificate
},app);
app.use(express.static('static'));
var io = require('socket.io')(httpsServer);
var port = process.env.PORT || 8082;
io.on('connection',function(socket){
console.log("a user connected..."+ socket.handshake.query.name);
socket.on('message',function(data){
io.emit('message', data);
})
});
httpsServer.listen(port, function(){
console.log('listening on port '+ port + '(https)...');
});