Exemplo n.º 1
0
 protected function applySubscriptions()
 {
     foreach ($this->subscriptions as $subscription) {
         $subscribeAction = function ($frame, $ackResolver = null) use($subscription) {
             $message = new Message($frame, $this->client);
             if ($ackResolver) {
                 $message->setAckResolver($ackResolver);
             }
             $subscription['action']($message, $this);
         };
         if ($subscription['ack']) {
             $this->client->subscribeWithAck($subscription['pipe'], $subscription['ack_mode'], $subscribeAction);
         } else {
             $this->client->subscribe($subscription['pipe'], $subscribeAction);
         }
     }
 }
Exemplo n.º 2
0
 private function getConnectedClient(InputStreamInterface $input, OutputStreamInterface $output)
 {
     $client = new Client($input, $output, array('vhost' => 'localhost'));
     $client->connect();
     $input->emit('frame', array(new Frame('CONNECTED')));
     return $client;
 }