<?php //开启服务 //http://192.168.22.171:8080/WS.php //访问服务 //http://192.168.22.171:8080/chating.html // http://www.jb51.net/article/48019.htm error_reporting(E_ALL); ob_implicit_flush(true); set_time_limit(0); $ws = new WS('192.168.22.171', 8000); $ws->run(); class WS { public $sockets; public $users; public $master; public function __construct($address, $port) { $this->master = $this->WebSocket($address, $port); $this->sockets = array('s' => $this->master); } function run() { while (true) { $changes = $this->sockets; socket_select($changes, $write = NULL, $except = NULL, NULL); $this->logs("run ===> 1"); foreach ($changes as $sock) { if ($sock == $this->master) { $this->logs("run ===> 2");
/** * Производит запуск веб-приложения * */ public function run() { try { if (!isset(self::$component_names['CMSStockroom'])) { Core::load('CMS.Stockroom'); } if (!isset(self::$component_names['CMSFSPages'])) { Core::load('CMS.FSPages'); } self::before_run(CMS::env()); // Если скрипт запущен из командной строки, то веб-приложение не запускается //TODO: create cli_application if (!isset($_SERVER['HTTP_HOST']) && !isset($_SERVER['REQUEST_URI'])) { CMS::$is_cli = true; Core::load('CMS.CLI'); CMS_CLI::run(); return; } if (self::$enable_rest) { self::application()->dispatcher(); } return WS::run(self::application()->cms_action()); } catch (Exception $e) { self::root_catcher($e); } }