diff options
author | Marvin Borner | 2018-08-27 00:47:26 +0200 |
---|---|---|
committer | Marvin Borner | 2018-08-27 00:47:26 +0200 |
commit | 06031351cf00986e7c2118ddcf892fa1c7e7234e (patch) | |
tree | 801754cc06cc853c9a0a59761bf81705871ff17d /infrastructure/Console/Commands/WebSocketServerCommand.php | |
parent | d18377e2f3d5506775e78d9b5557162f710c65b5 (diff) |
Added basic websocket service
Diffstat (limited to 'infrastructure/Console/Commands/WebSocketServerCommand.php')
-rw-r--r-- | infrastructure/Console/Commands/WebSocketServerCommand.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/infrastructure/Console/Commands/WebSocketServerCommand.php b/infrastructure/Console/Commands/WebSocketServerCommand.php new file mode 100644 index 0000000..4723b29 --- /dev/null +++ b/infrastructure/Console/Commands/WebSocketServerCommand.php @@ -0,0 +1,38 @@ +<?php + +namespace Infrastructure\Console\Commands; + +use Illuminate\Console\Command; +use Infrastructure\Http\WebSocketController; +use Ratchet\Http\HttpServer; +use Ratchet\Server\IoServer; +use Ratchet\WebSocket\WsServer; + +class WebSocketServerCommand extends Command +{ + /** + * The console command name. + * + * @var string + */ + protected $name = 'websocket'; + + /** + * Execute the console command. + * + * @return void + */ + public function fire() + { + $server = IoServer::factory( + new HttpServer( + new WsServer( + new WebSocketController() + ) + ), + 1337 + ); + $this->line('Started server.'); + $server->run(); + } +}
\ No newline at end of file |