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); } } }
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; }