Property | Type | Description | |
---|---|---|---|
$_auto_reconnect | Set to true when the client is supposed to reconnect automatically. | ||
$_definition | The DataSift stream definition object. | ||
$_eventHandler | The event handler object. | ||
$_hashes | The array of hashes to be consumed if using multi | ||
$_is_multi | True if this is consuming multiple hashes | ||
$_state | State active or stopped. | ||
$_user | DataSift object |
Method | Description | |
---|---|---|
consume ( boolean $auto_reconnect = true ) : void | Once an instance of a StreamConsumer is ready for use, call this to start consuming. Extending classes should implement onStart to handle actually starting. | |
factory ( string $user, string $type, mixed $definition, string $eventHandler ) : DataSift_StreamConsumer | Factory function. Creates a StreamConsumer-derived object for the given type. | |
stop ( ) : void | 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. |
Method | Description | |
---|---|---|
__construct ( DataSift_User $user, mixed $definition, DataSift_IStreamConsumerEventHandler $eventHandler ) | Constructor. Do not use this directly, use the factory method instead. | |
onConnect ( ) : void | This is called when the underlying stream is connected. | |
onData ( $json ) : void | This is called when a complete JSON item is received. | |
onDeleted ( array $interaction, string $hash = false ) : void | This is called for each DELETE request received from the stream and must be implemented in extending classes. | |
onDisconnect ( ) : void | This is called when the underlying stream is disconnected. | |
onError ( string $message ) : void | This is called when an error notification is received on a stream connection. | |
onInteraction ( array $interaction, boolean $hash = false ) : void | This is called for each interaction received from the stream and must be implemented in extending classes. | |
onStart ( ) : void | Called when the consumer should start consuming the stream. | |
onStatus ( string $type, array $info = [] ) : void | Called for each status message received from the stream. | |
onStop ( string $reason = '' ) : void | Default implementation of onStop. It's unlikely that this method will ever be used in isolation, but rather it should be called as the final step in the extending class's implementation. | |
onStopped ( string $reason = '' ) : void | This is called when the consumer is stopped. | |
onWarning ( string $message ) : void | This is called when a warning notification is received on a scream connection. |
protected __construct ( DataSift_User $user, mixed $definition, DataSift_IStreamConsumerEventHandler $eventHandler ) | ||
$user | DataSift_User | The user this consumer will run as. |
$definition | mixed | CSDL string, a Definition object, or an array of hashes. |
$eventHandler | DataSift_IStreamConsumerEventHandler | The object that will receive events. |
public static factory ( string $user, string $type, mixed $definition, string $eventHandler ) : DataSift_StreamConsumer | ||
$user | string | Use DataSift_User object. |
$type | string | Use the TYPE_ constants |
$definition | mixed | CSDL string or a Definition object. |
$eventHandler | string | The object that will receive events. |
return | DataSift_StreamConsumer | The consumer object |
protected onDisconnect ( ) : void | ||
return | void |
protected $_auto_reconnect |