add bind option
This commit is contained in:
parent
4a1708abf5
commit
f29e7ca48f
|
@ -43,7 +43,8 @@ $ php server/src/resource/server.php
|
||||||
The server can be run with verbosity:
|
The server can be run with verbosity:
|
||||||
|
|
||||||
* `-v` or `--verbose` to show server messages
|
* `-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!
|
Open `http://your.local.ip:15000` and enjoy!
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,12 @@ use Ratchet\WebSocket\WsServer;
|
||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
|
|
||||||
$options = getopt(
|
$options = getopt(
|
||||||
'v',
|
'vmb:',
|
||||||
['verbose', 'vv']
|
['verbose', 'message', 'bind:']
|
||||||
);
|
);
|
||||||
|
|
||||||
$serverOutput = new Output(isset($options['v']) || isset($options['verbose']));
|
$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);
|
$server = new Server($serverOutput);
|
||||||
$shell = new Shell();
|
$shell = new Shell();
|
||||||
|
|
||||||
|
@ -202,7 +202,8 @@ $server->addMessageHandler('messages', function (ConnectionInterface $from, arra
|
||||||
|
|
||||||
$webSocker = IoServer::factory(
|
$webSocker = IoServer::factory(
|
||||||
new HttpServer(new WsServer($server)),
|
new HttpServer(new WsServer($server)),
|
||||||
14598
|
14598,
|
||||||
|
$options['b'] ?? $options['bind'] ?? '0.0.0.0'
|
||||||
);
|
);
|
||||||
|
|
||||||
$webSocker->run();
|
$webSocker->run();
|
||||||
|
|
Loading…
Reference in a new issue