Example #1
0
 public function __construct()
 {
     parent::__construct();
     $this['debug'] = true;
     $this->register(new TwigServiceProvider(), array('twig.path' => __DIR__ . '/../../views', 'twig.options' => array('cache' => __DIR__ . '/../../cache/', 'strict_variables' => true)));
     $this->register(new MonologServiceProvider());
     $this['monolog.handler'] = function (WebApplication $app) {
         return new NullHandler();
     };
     $this['monolog.level'] = function () {
         return Logger::DEBUG;
     };
     $this['monolog.name'] = 'Gloubster-Server';
     $this['configuration'] = $this->share(function (WebApplication $app) {
         return new Configuration(file_get_contents(__DIR__ . '/../../config/config.json'), array(file_get_contents(__DIR__ . '/../../resources/configuration.schema.json')));
     });
     $this->register(new SessionServiceProvider());
     $this['session.storage'] = $this->share(function (WebApplication $app) {
         return new NativeSessionStorage(array(), SessionHandler::factory($this['configuration']));
     });
     $this->register(new AsseticExtension(), array('assetic.path_to_web' => __DIR__ . '/../../www/assets', 'assetic.options' => array('debug' => $this['debug']), 'assetic.filters' => $this->protect(function ($fm) {
         $fm->set('yui_css', new CssCompressorFilter('/usr/local/bin/yuicompressor-2.4.7.jar'));
         $fm->set('yui_js', new JsCompressorFilter('/usr/local/bin/yuicompressor-2.4.7.jar'));
     }), 'assetic.assets' => $this->protect(function ($am, $fm) {
         $am->set('base_css', new AssetCache(new AssetCollection(array(new FileAsset(__DIR__ . '/../../components/bootstrap.css/css/bootstrap.css', array($fm->get('yui_css'))), new FileAsset(__DIR__ . '/../../views/application.css', array($fm->get('yui_css'))))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('modernizr', new AssetCache(new FileAsset(__DIR__ . '/../../components/modernizr/modernizr.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('underscore', new AssetCache(new FileAsset(__DIR__ . '/../../components/underscore/underscore.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('backbone', new AssetCache(new FileAsset(__DIR__ . '/../../components/backbone/backbone.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('hogan', new AssetCache(new FileAsset(__DIR__ . '/../../components/hogan/web/builds/2.0.0/hogan-2.0.0.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('filesizejs', new AssetCache(new FileAsset(__DIR__ . '/../../components/filesize.js/lib/filesize.min.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('relativedate', new AssetCache(new FileAsset(__DIR__ . '/../../components/relative-date/lib/relative-date.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('when', new AssetCache(new FileAsset(__DIR__ . '/../../components/when/when.js', array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('bootstrap_js', new AssetCache(new AssetCollection(array(new FileAsset(__DIR__ . '/../../components/bootstrap.css/js/bootstrap.js')), array($fm->get('yui_js'))), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->set('bootstrap_img', new \Assetic\Asset\AssetCache(new FileAsset(__DIR__ . '/../../components/bootstrap.css/img/glyphicons-halflings.png'), new FilesystemCache(__DIR__ . '/../../cache/assetic')));
         $am->get('base_css')->setTargetPath('css/styles.css');
         $am->get('bootstrap_img')->setTargetPath('img/glyphicons-halflings.png');
         $am->get('modernizr')->setTargetPath('js/modernizr.js');
         $am->get('hogan')->setTargetPath('js/hogan.js');
         $am->get('filesizejs')->setTargetPath('js/filesize.js');
         $am->get('relativedate')->setTargetPath('js/relative-date.js');
         $am->get('backbone')->setTargetPath('js/backbone.js');
         $am->get('underscore')->setTargetPath('js/underscore.js');
         $am->get('when')->setTargetPath('js/when.js');
         $am->get('bootstrap_js')->setTargetPath('js/bootstrap.js');
     })));
     $this['twig'] = $this->share($this->extend('twig', function ($twig, $app) {
         $twig->setLexer(new \Twig_Lexer($twig, array('tag_comment' => array('{#', '#}'), 'tag_block' => array('{%', '%}'), 'tag_variable' => array('${', '}'))));
         return $twig;
     }));
 }
 /**
  * {@inheritdoc}
  */
 public function register(GloubsterServerInterface $server)
 {
     $server['websocket-application.started'] = false;
     $server['websocket-application'] = new WebsocketApplication($server['monolog']);
     $server['websocket-application.socket'] = new Reactor($server['loop']);
     $server['dispatcher']->on('start', function ($server) {
         // Setup websocket server
         $server['websocket-application.socket']->listen($server['configuration']['websocket-server']['port'], $server['configuration']['websocket-server']['address']);
         $server['monolog']->addInfo(sprintf('Websocket Server listening on %s:%d', $server['configuration']['websocket-server']['address'], $server['configuration']['websocket-server']['port']));
         $server['websocket-server'] = new IoServer(new WsServer(new SessionProvider(new WampServer($server['websocket-application']), SessionHandler::factory($server['configuration']))), $server['websocket-application.socket'], $server['loop']);
         $server['dispatcher']->emit('websocket-application-connected', array($server['websocket-application']));
         $server['websocket-application.started'] = true;
     });
     $server['dispatcher']->on('stop', function ($server) {
         $server['websocket-application.socket']->shutdown();
         $server['monolog']->addInfo('Websocket Server shutdown');
         $server['websocket-application.started'] = false;
     });
 }
Example #3
0
 /**
  * @dataProvider getUnsupportedTypes
  * @expectedException Gloubster\Exception\RuntimeException
  */
 public function testFactoryUnsupported($format)
 {
     $conf = $this->getTestConfiguration();
     $conf['session-server'] = array("type" => $format, "host" => "localhost", "port" => 11211);
     SessionHandler::factory($conf);
 }