/**
  * Get the IO driver.
  *
  * @param [type] $driver [description]
  *
  * @return [type] [description]
  */
 private function getDriver($driver)
 {
     $class = $this->option('class');
     $ratchetServer = new IpBlackList(new $class($this));
     foreach (config('ratchet.blackList')->all() as $host) {
         $ratchetServer->blockAddress($host);
     }
     if ($driver == 'WsServer') {
         return $this->getWsServerDriver($ratchetServer);
     }
     return $ratchetServer;
 }
Exemple #2
0
/**
 * Create WS server
 * 
 * @global Ratchet\Server\IoServer $server
 * @global array $config
 */
function createServer()
{
    global $server, $config;
    $app = new Chat($config);
    //ip blacklist
    if (isset($config['IpBlackList']) && is_array($config['IpBlackList'])) {
        $app = new IpBlackList($app);
        foreach ($config['IpBlackList'] as $ipBlackList) {
            $app->blockAddress($ipBlackList);
        }
    }
    //session
    $session = new SessionProvider($app, $config);
    //websocket
    $wsServer = new WsServer($session);
    //limit origins
    if (isset($config['allowedOrigins']) && is_array($config['allowedOrigins'])) {
        $wsServer = new OriginCheck($wsServer, $config['allowedOrigins']);
    }
    $server = MgRTC\Server::factory(new HttpServer($wsServer), $config['port']);
}