Predis\Client::pubSubLoop PHP Method

pubSubLoop() public method

Creates a new publish/subscribe context and returns it, or starts its loop inside the optionally provided callable object.
public pubSubLoop ( ) : Consumer | null
return Predis\PubSub\Consumer | null
    public function pubSubLoop()
    {
        return $this->sharedContextFactory('createPubSub', func_get_args());
    }

Usage Example

Esempio n. 1
0
 /**
  * @group disconnected
  */
 public function testPubSubLoopWithArrayAndCallableExecutesPubSub()
 {
     // NOTE: we use a subscribe count of 0 in the fake message to trick
     //       the context and to make it think that it can be closed
     //       since there are no more subscriptions active.
     $message = array('subscribe', 'channel', 0);
     $options = array('subscribe' => 'channel');
     $connection = $this->getMock('Predis\\Connection\\SingleConnectionInterface');
     $connection->expects($this->once())->method('read')->will($this->returnValue($message));
     $callable = $this->getMock('stdClass', array('__invoke'));
     $callable->expects($this->once())->method('__invoke');
     $client = new Client($connection);
     $client->pubSubLoop($options, $callable);
 }