Author: Stuart Dallas (stuart@3ft9.com)
Ejemplo n.º 1
0
 /**
  * Called for each interaction consumed.
  *
  * @param DataSift_StreamConsumer $consumer    The consumer sending the
  *                                             event.
  * @param array                   $interaction The interaction data.
  * @param string                  $hash        The hash of the stream that
  *                                             matched this interaction.
  *
  * @return void
  */
 public function onInteraction($consumer, $interaction, $hash)
 {
     echo 'Type: ' . $interaction['interaction']['type'] . "\n";
     echo 'Content: ' . $interaction['interaction']['content'] . "\n--\n";
     // Stop after 10
     if ($this->_num-- == 1) {
         echo "Stopping consumer...\n";
         $consumer->stop();
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns a DataSift_StreamConsumer-derived object for this definition,
  * for the given type.
  *
  * @param string $type The consumer type for which to construct a consumer.
  * @param DataSift_IStreamConsumerEventHandler $eventHandler An instance of DataSift_IStreamConsumerEventHandler
  *
  * @return DataSift_StreamConsumer The consumer object.
  * @throws DataSift_Exception_InvalidData
  * @see DataSift_StreamConsumer
  */
 public function getConsumer($type, $eventHandler)
 {
     return DataSift_StreamConsumer::factory($this->_user, $type, $this, $eventHandler);
 }
Ejemplo n.º 3
0
 /**
  * Returns a DataSift_StreamConsumer-derived object for the given hashes,
  * for the given type.
  *
  * @param string $type The consumer type for which to construct a consumer.
  * @param string $hashes An array containing hashes and/or Definition objects to be consumed.
  * @param DataSift_IStreamConsumerEventHandler $eventHandler The object that will receive events.
  *
  * @return DataSift_StreamConsumer The consumer object.
  * @throws DataSift_Exception_InvalidData
  * @see DataSift_StreamConsumer
  */
 public function getMultiConsumer($type = DataSift_StreamConsumer::TYPE_HTTP, $hashes, $eventHandler)
 {
     return DataSift_StreamConsumer::factory($this, $type, $hashes, $eventHandler);
 }
Ejemplo n.º 4
0
 /**
  * Constructor.
  *
  * @param DataSift_User $user          The authenticated user
  * @param mixed         $definition    CSDL string, Definition object, or array of hashes
  * @param mixed         $eventHandler  An object that implements IStreamConsumerEventHandler
  *
  * @throws DataSift_Exception_InvalidData
  * @throws DataSift_Exceotion_CompileFailed
  * @throws DataSift_Exception_APIError
  * @see DataSift_StreamConsumer::__construct
  */
 public function __construct($user, $definition, $eventHandler)
 {
     parent::__construct($user, $definition, $eventHandler);
 }