-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwww.js
More file actions
executable file
·40 lines (33 loc) · 1.23 KB
/
www.js
File metadata and controls
executable file
·40 lines (33 loc) · 1.23 KB
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
39
40
#!/usr/bin/env node
var debug = require('debug')('my-application');
var app = require('./config/app');
var db = require('./config/db');
var router = require('./config/router');
var config = require('./config/config');
var fs = require('fs');
var http = require('http');
var https = require('https');
var socketIO = require("socket.io");
var webRTC = require("webrtc.io");
var privateKey = fs.readFileSync('./keys/server.key');
var certificate = fs.readFileSync('./keys/server.crt');
db.connect(config['development']);
db.configure();
router.start(app);
var httpServer = http.createServer(app);
var httpsServer = https.createServer({ key: privateKey, cert: certificate }, app);
//httpServer.listen(3000, log);
httpsServer.listen(443)
var io = socketIO.listen(httpServer.listen(3000, log));
webRTC.listen(9000);
io.sockets.on('connection', function (socket) {
socket.on('send', function (data) {
io.sockets.emit('message', data);
});
});
function log() {
var address = this.address();
console.info("=> Application starting in " + app.get("env") + " on http://" + address.address + ":" + address.port + "...");
console.info("=> Press CTRL+C to shutdown server");
debug('Express server listening on port ' + address.port);
}