芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/joolsmen.com/chat/vendor/cboden/ratchet/src/Ratchet/App.php
httpHost = $httpHost; $this->port = $port; $socket = new Reactor($address . ':' . $port, $loop); $this->routes = new RouteCollection; $this->_server = new IoServer(new HttpServer(new Router(new UrlMatcher($this->routes, new RequestContext))), $socket, $loop); $policy = new FlashPolicy; $policy->addAllowedAccess($httpHost, 80); $policy->addAllowedAccess($httpHost, $port); if (80 == $port) { $flashUri = '0.0.0.0:843'; } else { $flashUri = 8843; } $flashSock = new Reactor($flashUri, $loop); $this->flashServer = new IoServer($policy, $flashSock); } /** * Add an endpoint/application to the server * @param string $path The URI the client will connect to * @param ComponentInterface $controller Your application to server for the route. If not specified, assumed to be for a WebSocket * @param array $allowedOrigins An array of hosts allowed to connect (same host by default), ['*'] for any * @param string $httpHost Override the $httpHost variable provided in the __construct * @return ComponentInterface|WsServer */ public function route($path, ComponentInterface $controller, array $allowedOrigins = array(), $httpHost = null) { if ($controller instanceof HttpServerInterface || $controller instanceof WsServer) { $decorated = $controller; } elseif ($controller instanceof WampServerInterface) { $decorated = new WsServer(new WampServer($controller)); $decorated->enableKeepAlive($this->_server->loop); } elseif ($controller instanceof MessageComponentInterface) { $decorated = new WsServer($controller); $decorated->enableKeepAlive($this->_server->loop); } else { $decorated = $controller; } if ($httpHost === null) { $httpHost = $this->httpHost; } $allowedOrigins = array_values($allowedOrigins); if (0 === count($allowedOrigins)) { $allowedOrigins[] = $httpHost; } if ('*' !== $allowedOrigins[0]) { $decorated = new OriginCheck($decorated, $allowedOrigins); } //allow origins in flash policy server if(empty($this->flashServer) === false) { foreach($allowedOrigins as $allowedOrgin) { $this->flashServer->app->addAllowedAccess($allowedOrgin, $this->port); } } $this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET'))); return $decorated; } /** * Run the server by entering the event loop */ public function run() { $this->_server->run(); } }