作者:bfoxwel
项目:votifie
/**
* 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();
}
作者:kranti5
项目:LaravelRatchetChatRoo
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$port = intval($this->option('port'));
$this->info("Starting chat web socket server on port " . $port);
$server = IoServer::factory(new HttpServer(new WsServer(new Chat())), 8082);
$server->run();
}
作者:studentjaso
项目:laravel-5-sockets-and-queue-asyn
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$port = env('SOCKET_PORT');
$this->info('Websocket is running on port ' . $port);
$server = IoServer::factory(new HttpServer(new WsServer(new \App\Services\Websocket())), $port);
$server->run();
}
作者:paddy
项目:symfony-cha
protected function execute(InputInterface $input, OutputInterface $output)
{
$chat = $this->getContainer()->get('chat');
$server = IoServer::factory(new HttpServer(new WsServer($chat)), 8080);
$server->run();
echo "Server started";
}
作者:viktor
项目:cha
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->info('Starting web socket server...');
$this->server = IoServer::factory(new HttpServer(new WsServer(new Chat())), 8080, '0.0.0.0');
$this->info('To stop the web socket server press "Ctrl" + "C"');
$this->server->run();
}
作者:tim9
项目:webCha
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;
declare (ticks=1);
register_shutdown_function(array($this, 'stopCommand'));
set_error_handler(array($this, 'errorHandler'));
if (function_exists("pcntl_signal")) {
pcntl_signal(SIGTERM, [$this, 'stopCommand']);
pcntl_signal(SIGINT, [$this, 'stopCommand']);
} else {
}
$this->isDebug = $input->getArgument('isDebug');
$port = $input->getOption('port');
$chat = $this->container->get('app.chat.handler');
$chat->setIsDebug($this->isDebug);
$messageManager = new MessageManager($chat);
$messageManager->setIsDebug($this->isDebug);
$server = IoServer::factory(new HttpServer(new WsServer($messageManager)), $port);
if ($this->isDebug) {
$redis = $this->container->get('snc_redis.default');
$server->loop->addPeriodicTimer(5, function () use($redis, $messageManager) {
$memory = memory_get_usage();
echo "Send messages. Redis value: " . $redis->get('value') . "\r\n";
$info = array();
$info['message'] = "Redis value: " . $redis->get('value') . "; Memory: " . $memory;
$info['type'] = 'message';
$info['from'] = 'me';
$messageManager->sendAll(json_encode($info));
});
}
$this->logMessage("Start server.");
$server->run();
$this->logMessage("Finish execute daemon.");
}
作者:ov
项目:php-pm-reacto
public function execute(InputInterface $input, OutputInterface $output)
{
/**
* @var \Symfony\Component\Console\Helper\FormatterHelper
*/
$formatter = $this->getHelper('formatter');
$output->writeln($formatter->formatSection('IO', 'Start development server'));
// $loop = \React\EventLoop\Factory::create();
$bridgeName = $input->getOption('bridge');
switch (strtolower($bridgeName)) {
case 'phalcony':
$bridge = new Phalcony();
break;
case 'hello':
default:
$bridge = new SimpleBridge();
break;
}
$bridge->on('open', function (ConnectionInterface $conn, RequestInterface $request = null) use(&$formatter, $output) {
$section = $formatter->formatSection('IO', 'Connection is open from ' . $request->getHost() . ' on ' . date('h:i:s') . ' : ' . $request->getUrl());
$output->writeln($section);
});
$bridge->on('close', function (ConnectionInterface $conn, $timer) use(&$formatter, $output) {
$output->writeln($formatter->formatSection('IO', sprintf('Connection is closed. Request completed %.4F sec.', $timer)));
});
$bridge->on('error', function (Exception $e) use(&$formatter, $output) {
$output->writeln($formatter->formatBlock(array('[App]', $e->getMessage(), 'in the ' . $e->getFile() . ' file on ' . $e->getLine() . ' line'), 'error'));
});
$listen = $input->getOption('listen');
$port = $input->getOption('port');
$server = IoServer::factory(new HttpServer($bridge), $port, $listen);
$server->run();
}
作者:paulchyrilo
项目:hello_larave
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$port = intval($this->argument('port'));
$this->info("Starting chat web socket server on port " . $port);
$server = IoServer::factory(new HttpServer(new WsServer(new ChatController())), $port);
$server->run();
}
作者:pmil
项目:php-cha
/**
* @param AbstractMultiRoomServer $chatServer
* @param int $port
* @param string $ip
* @return IoServer
*/
public static function run(AbstractMultiRoomServer $chatServer, $port, $ip = '0.0.0.0')
{
$wsServer = new WsServer($chatServer);
$http = new HttpServer($wsServer);
$server = IoServer::factory($http, $port, $ip);
$server->run();
return $server;
}
作者:pacho10
项目:redbpi
/**
* @param Chat $chatServer
* @param int $port
* @param string $ip
* @return IoServer
*/
public static function run(Chat $chatServer, $port, $ip = '127.0.0.1')
{
$wsServer = new WsServer($chatServer);
$http = new HttpServer($wsServer);
$server = IoServer::factory($http, $port, $ip);
$server->run();
return $server;
}
作者:rest-o
项目:the-tabl
protected function execute(InputInterface $input, OutputInterface $output)
{
$port = $input->getOption('port');
$address = $input->getOption('address');
$server = IoServer::factory(new HttpServer(new WsServer(new Server($this->getContainer()->get('croupier')))), $port, $address);
$output->writeln(sprintf('<info>Starting Croupier server on %s:%d.</info>', $address, $port));
$server->run();
}
作者:subins200
项目:Francium-DiffSocke
private function startServer()
{
$ip = $this->config['server']['host'];
$port = $this->config['server']['port'];
$server = IoServer::factory(new HttpServer(new WsServer(new \Fr\DiffSocket\Server($this->config))), $port, $ip);
echo "Server started on {$ip}:{$port}\n";
$server->run();
}
作者:ov
项目:php-pm-reacto
public function newWorker($output, $formatter, $listen, $port, $bridge)
{
$pid = pcntl_fork();
if (!$pid) {
$output->writeln($formatter->formatSection('App', 'Start slave worker on ' . $listen . ':' . $port . ' pid: ' . $pid));
$this->slots[] = $server = IoServer::factory(new HttpServer($bridge), $port, $listen);
$server->run();
}
}
作者:edcorewe
项目:domino
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$address = $this->option('address');
$port = intval($this->option('port'));
$this->info('Starting web socket server on port ' . $port);
$server = IoServer::factory(new HttpServer(new WsServer($this->connection)), $port, $address);
$this->connection->setServer($server);
$server->run();
}
作者:HeliosD
项目:BlogWim
protected function execute(InputInterface $input, OutputInterface $output)
{
//$chat = $this->getContainer()->get('heliosblog.chat');
$memcache = new \Memcache();
$memcache->connect('localhost', 11211);
$server = IoServer::factory(new HttpServer(new WsServer(new SessionProvider(new Chat1(), new Handler\MemcacheSessionHandler($memcache)))), 8080);
echo "Chat server is running\n";
$server->run();
}
作者:djom2
项目:TetrisRemot
protected function execute(InputInterface $input, OutputInterface $output)
{
$port = $input->getOption('port');
if (!$port) {
$port = 4567;
}
$server = IoServer::factory(new HttpServer(new WsServer($this->getContainer()->get('tetris.socket_server'))), $port);
$output->writeln("Server running on port {$port}");
$server->run();
}
作者:bitqi
项目:laravel5-rache
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$port = (int) $this->option("port");
if (!$port) {
$port = 7778;
}
$server = IoServer::factory(new HttpServer(new WsServer($this->chat)), $port);
$this->line("<info>Listening on port <comment>" . $port . "</comment>.</info>");
$server->run();
}
作者:jhekasof
项目:shopping-lis
public function startAction()
{
$request = $this->getRequest();
if (!$request instanceof ConsoleRequest) {
throw new \RuntimeException('You can only use this action from a console!');
}
$config = $this->getServiceLocator()->get('Config');
$server = IoServer::factory(new HttpServer(new WsServer(new ShoppingList())), $config['web_sockets']['port']);
echo 'Running...' . PHP_EOL;
$server->run();
}
作者:beingsan
项目:SeminarioLocawe
/**
* Execute the console command.
*
* @return void
*/
public function fire()
{
echo 'Iniciando servidor...' . PHP_EOL;
$controller = new Controller();
$server = IoServer::factory(new HttpServer(new WsServer($controller)), 777);
$loop = $server->loop;
$loop->addPeriodicTimer(5, function () use($controller) {
$controller->sendCounterMessage();
});
$server->run();
}
作者:guoyu0
项目:admin-biarq-co
public function start($adress = '127.0.0.1', $port = 8000, $ssl = false)
{
$memcache = new \Memcache();
$memcache->connect('localhost', 11211);
$chat = new Chat();
$handler = new Handler\MemcacheSessionHandler($memcache, array('prefix' => ''));
$session = new SessionProvider($chat, $handler, array('adapter' => 'Php', 'session.name' => 'PHPSESSID', 'session.save_handler' => 'memcached', 'session.save_path' => 'localhost:11211'));
// Run the server application through the WebSocket protocol on port 8000
$server = IoServer::factory(new WsServer($session), 8000);
$server->run();
}