/** * Main server loop * * @return void This method does not return! */ public function run() { $this->connectionManager->listen(); while (true) { /* * If there's nothing changed on any of the sockets, the server * will sleep and other processes will have a change to run. Control * this behaviour with the timeout options. */ $this->connectionManager->selectAndProcess(); } }
/** * Main server loop * * @return void This method does not return! */ public function run() { $this->connectionManager->listen(); while (true) { /* * If there's nothing changed on any of the sockets, the server * will sleep and other processes will have a change to run. Control * this behaviour with the timeout options. */ $this->connectionManager->selectAndProcess(); /* * If the application wants to perform periodic operations or queries and push updates to clients based on the result then that logic can be implemented in the 'onUpdate' method. */ foreach ($this->applications as $application) { if (method_exists($application, 'onUpdate')) { $application->onUpdate(); } } } }
/** * @depends testConstructor * @param ConnectionManager $instance */ public function testCount($instance) { $this->assertTrue(is_numeric($instance->count())); }
/** * Constructor * * @param Server $server * @param ServerClientSocket $socket * @param array $options * @throws InvalidArgumentException */ public function __construct(ConnectionManager $manager, ServerClientSocket $socket, array $options = array()) { $this->manager = $manager; $this->socket = $socket; $this->logger = $manager->getLogger(); parent::__construct($options); $this->configureClientInformation(); $this->configurePayloadHandler(); $this->logger->info('Connected'); }
/** * Logs a message * * @param string $message * @param string $priority */ public function log($message, $priority = 'info') { $this->manager->log(sprintf('%s: %s:%d (%s): %s', __CLASS__, $this->getIp(), $this->getPort(), $this->getId(), $message), $priority); }