From f29e7ca48f20b5f349b7d9cb9d151cde06e6d445 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 11 Apr 2022 18:29:44 +0200 Subject: [PATCH] add bind option --- README.md | 3 ++- server/src/resource/server.php | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6f7c8c0..376f8df 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,8 @@ $ php server/src/resource/server.php The server can be run with verbosity: * `-v` or `--verbose` to show server messages -* `--vv` to show handlers messages +* `-m` or `--message` to show client messages +* `-b` or `--bind` to define server address to bind (default: `0.0.0.0`) Open `http://your.local.ip:15000` and enjoy! diff --git a/server/src/resource/server.php b/server/src/resource/server.php index 798a9cd..d324e30 100644 --- a/server/src/resource/server.php +++ b/server/src/resource/server.php @@ -8,12 +8,12 @@ use Ratchet\WebSocket\WsServer; use Ratchet\ConnectionInterface; $options = getopt( - 'v', - ['verbose', 'vv'] + 'vmb:', + ['verbose', 'message', 'bind:'] ); $serverOutput = new Output(isset($options['v']) || isset($options['verbose'])); -$messageOutput = new Output(isset($options['vv'])); +$messageOutput = new Output(isset($options['message'])); $server = new Server($serverOutput); $shell = new Shell(); @@ -202,7 +202,8 @@ $server->addMessageHandler('messages', function (ConnectionInterface $from, arra $webSocker = IoServer::factory( new HttpServer(new WsServer($server)), - 14598 + 14598, + $options['b'] ?? $options['bind'] ?? '0.0.0.0' ); $webSocker->run();