WebsocketServer.php 660 B

123456789101112131415161718192021
  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::$logFile = sprintf('%s/test-websocket-server.log', sys_get_temp_dir());
  14. Worker::$command = 'start';
  15. Worker::runAll();