Author: Stuart Dallas (stuart@3ft9.com)
Example #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();
     }
 }
Example #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);
 }
Example #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);
 }
Example #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);
 }