server change

main
Benjamin Kraft 2 years ago
parent 122f2a5e8d
commit 26d6c3c4e3
  1. 1
      package.json
  2. 11
      src/index.ts
  3. 2
      tsconfig.json

@ -3,6 +3,7 @@
"version": "2.0",
"private": true,
"main": "out/index.js",
"types": "src/index.ts",
"dependencies": {
"dotenv": "^16.0.3",
"https": "^1.0.0",

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

@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es6",
"target": "ES2022",
"module": "commonjs",
"sourceMap": true,
"alwaysStrict": true,

Loading…
Cancel
Save