WebsocketServer.php 580 B

1234567891011121314151617181920
  1. <?php
  2. declare(strict_types=1);
  3. use Workerman\Connection\TcpConnection;
  4. use Workerman\Protocols\Http\Request;
  5. use Workerman\Worker;
  6. require_once __DIR__ . '/vendor/autoload.php';
  7. if (!defined('STDIN')) define('STDIN', fopen('php://stdin', 'r'));
  8. if (!defined('STDOUT')) define('STDOUT', fopen('php://stdout', 'w'));
  9. if (!defined('STDERR')) define('STDERR', fopen('php://stderr', 'w'));
  10. $worker = new Worker("websocket://127.0.0.1:8081");
  11. //%action%
  12. Worker::$pidFile = sprintf('%s/test-websocket-server.pid', sys_get_temp_dir());
  13. Worker::$command = 'start';
  14. Worker::runAll();