'use strict'; import {log} from "./logger"; import {ConnectionManager} from "./manager"; import https = require('https'); import {Server} from 'socket.io'; const p2p = require('socket.io-p2p-server').Server; import fs = require('fs'); import ini = require('ini'); let rootDir = __dirname + '/..'; let httpsPort = ini.parse(fs.readFileSync(rootDir + '/env_config.ini', 'utf-8'))['nodejs_port']; let cert = fs.readFileSync(rootDir + '/ssl_certificate/cert.pem'); let key = fs.readFileSync(rootDir + '/ssl_certificate/key.pem'); let httpsServer = https.createServer({key: key, cert: cert}); let sIO = new Server(httpsServer, { cors: { origin: ["https://play.benjamin-kraft.local", "https://dev.play.benjamin-kraft.eu", "https://play.benjamin-kraft.eu"] } }); sIO.use(p2p); httpsServer.listen(httpsPort); let connectionManager = new ConnectionManager(sIO); // On new connection sIO.on('connection', socket => connectionManager.newSocket(socket)); log('startup', null, null, 'Server is listening on port ' + httpsPort);