public function subscribe(array $options = array()) { if (!empty($options['events'])) { $this->setEvents($options['events']); } try { $response = $this->_platform->post('/restapi/v1.0/subscription', array('eventFilters' => $this->getFullEventFilters(), 'deliveryMode' => array('transportType' => 'PubNub'))); $this->setSubscription($response->json(false)); $this->subscribeAtPubnub(); //TODO Subscription renewal when everything will become async $this->dispatch(self::EVENT_SUBSCRIBE_SUCCESS, new SuccessEvent($response)); return $response; } catch (Exception $e) { $this->reset(); $this->dispatch(self::EVENT_SUBSCRIBE_ERROR, new ErrorEvent($e)); throw $e; } }