Webpage for Games
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

35 lines
1.0 KiB

'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);