|
@@ -943,6 +943,7 @@ class PubSubContext implements \Iterator {
|
|
|
private $_redisClient, $_subscriptions, $_isStillValid, $_position;
|
|
|
|
|
|
public function __construct(Client $redisClient) {
|
|
|
+ $this->checkCapabilities($redisClient);
|
|
|
$this->_redisClient = $redisClient;
|
|
|
$this->_isStillValid = true;
|
|
|
$this->_subscriptions = false;
|
|
@@ -955,6 +956,16 @@ class PubSubContext implements \Iterator {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private function checkCapabilities(Client $redisClient) {
|
|
|
+ $profile = $redisClient->getProfile();
|
|
|
+ $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe');
|
|
|
+ if ($profile->supportsCommands($commands) === false) {
|
|
|
+ throw new \Predis\ClientException(
|
|
|
+ 'The current profile does not support PUB/SUB related commands'
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public function subscribe(/* arguments */) {
|
|
|
$this->writeCommand(self::SUBSCRIBE, func_get_args());
|
|
|
$this->_subscriptions = true;
|