stop() public method

This method can be called at any time to *request* that the consumer stop consuming. This method sets the state to STATE_STOPPING and it's up to the consumer implementation to notice that this has changed, stop consuming and call the onStopped method.
public stop ( ) : void
return void
Esempio 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();
     }
 }