|
|
|
@ -8,13 +8,11 @@ import https = require('https'); |
|
|
|
|
import {Server} from 'socket.io'; |
|
|
|
|
import fs = require('fs'); |
|
|
|
|
|
|
|
|
|
export function GameServer(){ |
|
|
|
|
const p2p = require('socket.io-p2p-server').Server; |
|
|
|
|
|
|
|
|
|
export function GameServer(useP2P: boolean){ |
|
|
|
|
let rootDir = __dirname + '/..'; |
|
|
|
|
|
|
|
|
|
require("dotenv").config(); |
|
|
|
|
const httpsPort = process.env["https_port"]; |
|
|
|
|
const httpsPort = parseInt(process.env["HTTPS_PORT"]); |
|
|
|
|
|
|
|
|
|
let cert = fs.readFileSync(rootDir + '/ssl_certificate/cert.pem'); |
|
|
|
|
let key = fs.readFileSync(rootDir + '/ssl_certificate/key.pem'); |
|
|
|
@ -26,7 +24,10 @@ export function GameServer(){ |
|
|
|
|
origin: ["https://play.benjamin-kraft.local", "https://dev.play.benjamin-kraft.eu", "https://play.benjamin-kraft.eu"] |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
sIO.use(p2p); |
|
|
|
|
if (useP2P){ |
|
|
|
|
const p2p = require('socket.io-p2p-server').Server; |
|
|
|
|
sIO.use(p2p); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
httpsServer.listen(httpsPort); |
|
|
|
|
|
|
|
|
|