server.php 504 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. use Ratchet\Http\HttpServer;
  3. use Ratchet\Server\IoServer;
  4. use Ratchet\WebSocket\WsServer;
  5. require 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
  6. require 'Handler.php';
  7. require 'WebSocketHandler.php';
  8. $port = 8080;
  9. if ($argc > 1) {
  10. $port = $argv[1];
  11. }
  12. echo "Starting server on port $port\n";
  13. $server = IoServer::factory(
  14. new HttpServer(
  15. new WsServer(
  16. new WebSocketHandler(
  17. new Handler()
  18. )
  19. )
  20. ),
  21. $port
  22. );
  23. $server->run();