From 2d2fe59eca303e2fe0ea36f831482bf10d8bb058 Mon Sep 17 00:00:00 2001 From: RblSb Date: Mon, 24 Feb 2020 15:07:37 +0300 Subject: Wow, same port for ws --- src/client/Main.hx | 13 ++++++++----- src/server/Main.hx | 11 ++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/client/Main.hx b/src/client/Main.hx index aa0a648..a95a9a2 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -2,8 +2,8 @@ package client; import haxe.Timer; import js.html.MouseEvent; -import js.html.ButtonElement; import js.html.KeyboardEvent; +import js.html.Event; import js.html.Element; import haxe.Json; import js.html.InputElement; @@ -33,11 +33,13 @@ class Main { static function main():Void new Main(); - public function new(?host:String, port = 4201) { + public function new(?host:String, ?port:String) { player = new Player(this); if (host == null) host = Browser.location.hostname; if (host == "") host = "localhost"; this.host = host; + if (port == null) port = Browser.location.port; + if (port == "") port = "80"; initListeners(); onTimeGet.run = () -> { @@ -56,7 +58,7 @@ class Main { }); } - function openWebSocket(host:String, port:Int):Void { + function openWebSocket(host:String, port:String):Void { ws = new WebSocket('ws://$host:$port'); ws.onmessage = onMessage; ws.onopen = () -> { @@ -89,8 +91,8 @@ class Main { }); } - ge("#queue_next").onclick = (e:MouseEvent) -> addVideoUrl(false); - ge("#queue_end").onclick = (e:MouseEvent) -> addVideoUrl(true); + ge("#queue_next").onclick = e -> addVideoUrl(false); + ge("#queue_end").onclick = e -> addVideoUrl(true); ge("#mediaurl").onkeydown = function(e:KeyboardEvent) { if (e.keyCode == 13) addVideoUrl(true); } @@ -361,6 +363,7 @@ class Main { function hideGuestLoginPanel():Void { ge("#guestlogin").style.display = "none"; ge("#chatline").style.display = "block"; + js.Browser.window.dispatchEvent(new Event("resize")); } function updateClients(newClients:Array):Void { 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 { -- cgit v1.2.3