public function run($useExternalEventLoop = false) { if (true === $useExternalEventLoop) { // Advertise the library we want to control the event loop echo "Declaring external event loop…\n"; $loop = new EventLoop($this); $this->server->setEventLoop($loop); } // Open main socket $this->server->run(); if (true === $useExternalEventLoop) { // Main advantage of external event loop : you can manage other events // Example : $tick = new \EvTimer(0, 1, [$this, 'evTick1s']); \Ev::run(); } }
public function run() { $this->server->run(); }
<?php ini_set('display_errors', 1); error_reporting(E_ALL); use WebSocket\Server; require __DIR__ . '/../vendor/autoload.php'; $server = new Server('127.0.0.1', 8000, false); // server settings: $server->setMaxClients(100); $server->setMaxConnectionsPerIp(100); $server->setMaxRequestsPerMinute(2000); $server->setCheckOrigin(false); // Hint: Status application should not be removed as it displays usefull server informations: $server->registerApplication('status', \WebSocket\Application\StatusApplication::getInstance()); $server->registerApplication('demo', \WebSocket\Application\DemoApplication::getInstance()); $server->run();