示例#1
0
/* (c) Anton Medvedev <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require __DIR__ . '/bootstrap.php';
use React\EventLoop\Factory as LoopFactory;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\Session\SessionProvider;
use Ratchet\WebSocket\WsServer;
// Use cli opt
$opt = getopt('', array('host::', 'port::', 'path::'));
// We need to configure application to use common parts.
$app = new ElfChat\Application();
$app->boot();
// Error logger.
ElfChat\Server\WebSocketServer\ErrorLogger::register($app['logger']);
$host = array_key_exists('host', $opt) ? $opt['host'] : 'localhost';
$port = array_key_exists('port', $opt) ? $opt['port'] : '8080';
$path = array_key_exists('path', $opt) ? $opt['path'] : '/';
$address = '0.0.0.0';
// 0.0.0.0 means receive connections from any
// Init Ratchet server
$loop = LoopFactory::create();
$ratchet = new Ratchet\App($host, $port, $address, $loop);
// Session Integration
$sessionWrapper = function ($component) use($app) {
    return new SessionProvider($component, $app['session.storage.handler'], array('name' => 'ELFCHAT'));
};
示例#2
0
文件: index.php 项目: elfchat/elfchat
<?php

if (!file_exists(__DIR__ . '/app/open/config.php')) {
    strpos($_SERVER['REQUEST_URI'], 'check.php') ? die('Script "check.php" does not found.') : header('Location: web/check.php');
    exit;
}
require_once __DIR__ . '/app/bootstrap.php';
$app = new ElfChat\Application();
$app->run();