aboutsummaryrefslogtreecommitdiffstats
path: root/src/server
diff options
context:
space:
mode:
authorRblSb <msrblsb@gmail.com>2020-02-24 15:07:37 +0300
committerRblSb <msrblsb@gmail.com>2020-02-24 15:07:37 +0300
commit2d2fe59eca303e2fe0ea36f831482bf10d8bb058 (patch)
tree9d11b7db916c9bf1aeef48b3fac0fec68f58acea /src/server
parent5ff624a196b3603983052b2139eefe788413e2f1 (diff)
Wow, same port for ws
Diffstat (limited to 'src/server')
-rw-r--r--src/server/Main.hx11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/server/Main.hx b/src/server/Main.hx
index 1e2094e..b5fe3a6 100644
--- a/src/server/Main.hx
+++ b/src/server/Main.hx
@@ -34,14 +34,12 @@ class Main {
static function main():Void new Main();
- public function new(port = 4200, wsPort = 4201) {
+ public function new(port = 4200, ?wsPort:Int) {
final envPort = (process.env : Dynamic).PORT;
if (envPort != null) port = envPort;
statePath = '$rootDir/user/state.json';
config = getUserConfig();
loadState();
- wss = new WSServer({port: wsPort});
- wss.on("connection", onConnect);
function exit() {
saveState();
process.exit();
@@ -77,9 +75,12 @@ class Main {
HttpServer.init(dir, '$rootDir/user/res');
Lang.init('$dir/langs');
- Http.createServer((req, res) -> {
+ final server = Http.createServer((req, res) -> {
HttpServer.serveFiles(req, res);
- }).listen(port);
+ });
+ server.listen(port);
+ wss = new WSServer({server: server, port: wsPort});
+ wss.on("connection", onConnect);
}
function getUserConfig():Config {
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage