add bind option

This commit is contained in:
Simon Vieille 2022-04-11 18:29:44 +02:00
parent 4a1708abf5
commit f29e7ca48f
Signed by: deblan
GPG key ID: 03383D15A1D31745
2 changed files with 7 additions and 5 deletions

View file

@ -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!

View file

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