-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
38 lines (31 loc) · 976 Bytes
/
app.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
32
33
34
35
36
37
38
const express = require('express');
const app = express();
const fs = require('fs');
const ssl = {
key: fs.readFileSync('./ssl/yuanchieh.com.key', 'utf8'),
cert: fs.readFileSync('./ssl/yuanchieh.com.crt', 'utf8'),
ca: [fs.readFileSync('./ssl/gdig2_bundle.crt', 'utf8')]
};
const server = require('https').createServer(ssl, app);
const io = require('socket.io')(server);
app.use(express.static(__dirname + '/'));
app.get('/', function (req, res, next) {
res.sendFile(__dirname + '/index.html');
});
io.on('connection', function (client) {
console.log('Client connected...');
client.on('candidate', function(data){
"use strict";
console.log(data);
client.broadcast.emit('msg', data);
});
client.on('sdp', function(data){
"use strict";
console.log(data);
client.broadcast.emit('msg', data);
});
});
server.listen(4200, ()=> {
"use strict";
console.log('server start at 4200');
});