diff options
| author | RblSb <msrblsb@gmail.com> | 2020-03-06 06:32:01 +0300 |
|---|---|---|
| committer | RblSb <msrblsb@gmail.com> | 2020-03-06 06:32:01 +0300 |
| commit | 0ca7420ad952c0332ab36e37596b0fa53e710325 (patch) | |
| tree | 7e64bbd60ff781df2d5c429f900ec18b75e44703 /src | |
| parent | 39767a4b71de751c2b4ee672c3985f52a62e039b (diff) | |
Move server port to config
Diffstat (limited to 'src')
| -rw-r--r-- | src/Types.hx | 1 | ||||
| -rw-r--r-- | src/client/Main.hx | 4 | ||||
| -rw-r--r-- | src/server/Main.hx | 14 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/Types.hx b/src/Types.hx index 41d5340..a98c7a1 100644 --- a/src/Types.hx +++ b/src/Types.hx @@ -8,6 +8,7 @@ typedef VideoData = { } typedef Config = { + port:Int, channelName:String, maxLoginLength:Int, maxMessageLength:Int, diff --git a/src/client/Main.hx b/src/client/Main.hx index 8ec1704..1552d38 100644 --- a/src/client/Main.hx +++ b/src/client/Main.hx @@ -2,11 +2,11 @@ package client; import haxe.crypto.Sha256; import haxe.Timer; +import haxe.Json; import js.html.MouseEvent; import js.html.KeyboardEvent; import js.html.Event; import js.html.Element; -import haxe.Json; import js.html.InputElement; import js.html.WebSocket; import js.Browser; @@ -38,7 +38,7 @@ class Main { static function main():Void new Main(); - public function new(?host:String, ?port:String) { + function new(?host:String, ?port:String) { player = new Player(this); if (host == null) host = Browser.location.hostname; if (host == "") host = "localhost"; diff --git a/src/server/Main.hx b/src/server/Main.hx index 033e2a0..5cac674 100644 --- a/src/server/Main.hx +++ b/src/server/Main.hx @@ -1,11 +1,9 @@ package server; import haxe.crypto.Sha256; -import js.lib.Date; import sys.FileSystem; import sys.io.File; import haxe.Timer; -import Client.ClientData; import haxe.Json; import js.Node.process; import js.Node.__dirname; @@ -13,6 +11,8 @@ import js.npm.ws.Server as WSServer; import js.npm.ws.WebSocket; import js.node.http.IncomingMessage; import js.node.Http; +import js.lib.Date; +import Client.ClientData; import Types.Config; import Types.Permission; import Types.UserList; @@ -43,9 +43,7 @@ class Main { static function main():Void new Main(); - public function new(port = 4200, ?wsPort:Int) { - final envPort = (process.env : Dynamic).PORT; - if (envPort != null) port = envPort; + function new() { statePath = '$rootDir/user/state.json'; // process.on("exit", exit); process.on("SIGINT", exit); // ctrl+c @@ -72,7 +70,9 @@ class Main { config.salt = generateConfigSalt(); localIp = Utils.getLocalIp(); globalIp = localIp; - this.port = port; + port = config.port; + final envPort = (process.env : Dynamic).PORT; + if (envPort != null) port = envPort; Utils.getGlobalIp(ip -> { globalIp = ip; @@ -88,7 +88,7 @@ class Main { HttpServer.serveFiles(req, res); }); server.listen(port); - wss = new WSServer({server: server, port: wsPort}); + wss = new WSServer({server: server}); wss.on("connection", onConnect); } |
