Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function register(GloubsterServerInterface $server)
 {
     $server['stomp-client.started'] = false;
     $server['stomp-client'] = $server->share(function (GloubsterServer $server) {
         $factory = new StompFactory($server['loop']);
         return $factory->createClient(array('host' => $server['configuration']['server']['host'], 'port' => $server['configuration']['server']['stomp-gateway']['port'], 'user' => $server['configuration']['server']['user'], 'passcode' => $server['configuration']['server']['password'], 'vhost' => $server['configuration']['server']['vhost']));
     });
     $server['dispatcher']->on('stop', function ($server) {
         $server['stomp-client']->disconnect();
         $server['stomp-client.started'] = false;
         $server['monolog']->addInfo('STOMP Server shutdown');
     });
     $component = $this;
     $server['dispatcher']->on('start', function ($server) use($component) {
         $server['stomp-client']->on('error', array($server, 'logError'));
         $server['stomp-client']->connect()->then(Curry::bind(array($component, 'activateService'), $server), Curry::bind(array($server, 'throwError')));
         $server['monolog']->addInfo('Connecting to STOMP Gateway...');
     });
 }
Ejemplo n.º 2
0
 public function register(GloubsterServerInterface $server)
 {
     $server['message-handler'] = $server->share(function ($server) {
         return new MessageHandler($server['stomp-client'], $server['monolog']);
     });
 }