本文整理汇总了PHP中Ratchet\Server\IoServer::run方法的典型用法代码示例。如果您正苦于以下问题:PHP IoServer::run方法的具体用法?PHP IoServer::run怎么用?PHP IoServer::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ratchet\Server\IoServer
的用法示例。
在下文中一共展示了IoServer::run方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
* Start Server
*/
public function start()
{
$loop = $this->createLoop();
$socket = $this->createSocket($loop, $this->port, $this->address);
$ioServer = new IoServer($this->component, $socket, $loop);
$this->logStart();
$ioServer->run();
}
示例2: socket_server
/**
* This method initialize the socket server
*
*/
public function socket_server()
{
if (!is_cli()) {
echo "This controller must run from command line interface only.\n";
return;
}
echo __DIR__;
$this->load->library('websocket_application');
$this->load->model('user_model');
$loop = Factory::create();
$socket = new Server($loop);
$socket->listen('8087', '0.0.0.0');
echo "Created websocket: ws://0.0.0.0:8087/\n";
$routes = new RouteCollection();
$users = $this->user_model->get_records();
foreach ($users as $user) {
$routes->add($user->record_id, new Route('/' . $user->record_id, array('_controller' => new WsServer(new Websocket_application()))));
echo "Created route: /" . $user->record_id . "\n";
}
$context = new RequestContext();
$matcher = new UrlMatcher($routes, $context);
$server = new IoServer(new HttpServer(new Router($matcher)), $socket, $loop);
$server->run();
}
示例3: run
/**
* Run the server by entering the event loop
*/
public function run()
{
$this->server->run();
}
示例4: testNoLoopProvidedError
public function testNoLoopProvidedError()
{
$this->setExpectedException('RuntimeException');
$io = new IoServer($this->app, $this->reactor);
$io->run();
}
示例5: Api
$argsize = count($argv);
if ($argsize == 1) {
echo colorize("Please specify a base uri eg.", "red") . colorize(" http://myhost.com/movim/\n", 'yellow');
exit;
}
if ($argsize == 2) {
echo colorize("Please specify a port eg.", "red") . colorize(" 8080\n", 'yellow');
exit;
}
$md = Modl\Modl::getInstance();
$infos = $md->check();
if ($infos != null) {
echo colorize("The database need to be updated before running the daemon\n", 'green');
foreach ($infos as $i) {
echo colorize($i . "\n", 'blue');
}
echo colorize("\nTo update the database run\n", 'green');
echo colorize("php mud.php db --set\n", 'purple');
exit;
}
$loop = Factory::create();
$core = new Core($loop, $argv[1], $argv[2]);
$app = new HttpServer(new WsServer($core));
$socket = new Reactor($loop);
$socket->listen($argv[2], '127.0.0.1');
$socketApi = new Reactor($loop);
new Api($socketApi, $core);
$socketApi->listen(1560);
$server = new IoServer($app, $socket, $loop);
$server->run();
示例6: run
/**
* Starts the prepared server.
*
* @return Freestream\WebSocket\WebSocketServer
*/
public function run()
{
$this->server->run();
return $this;
}