PHP Класс DataSift_StreamConsumer

Автор: Stuart Dallas ([email protected])
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_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

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
__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.

Описание методов

__construct() защищенный метод

Constructor. Do not use this directly, use the factory method instead.
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.

consume() публичный метод

Once an instance of a StreamConsumer is ready for use, call this to start consuming. Extending classes should implement onStart to handle actually starting.
public consume ( boolean $auto_reconnect = true ) : void
$auto_reconnect boolean Whether to reconnect automatically
Результат void

factory() публичный статический метод

Factory function. Creates a StreamConsumer-derived object for the given type.
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.
Результат DataSift_StreamConsumer The consumer object

onConnect() защищенный метод

This is called when the underlying stream is connected.
protected onConnect ( ) : void
Результат void

onData() защищенный метод

This is called when a complete JSON item is received.
protected onData ( $json ) : void
$json The JSON data.
Результат void

onDeleted() защищенный метод

This is called for each DELETE request received from the stream and must be implemented in extending classes.
protected onDeleted ( array $interaction, string $hash = false ) : void
$interaction array The interaction data structure
$hash string The stream hash.
Результат void

onDisconnect() защищенный метод

This is called when the underlying stream is disconnected.
protected onDisconnect ( ) : void
Результат void

onError() защищенный метод

This is called when an error notification is received on a stream connection.
protected onError ( string $message ) : void
$message string The error message
Результат void

onInteraction() защищенный метод

This is called for each interaction received from the stream and must be implemented in extending classes.
protected onInteraction ( array $interaction, boolean $hash = false ) : void
$interaction array The interaction data structure
$hash boolean
Результат void

onStart() абстрактный защищенный метод

Called when the consumer should start consuming the stream.
abstract protected onStart ( ) : void
Результат void

onStatus() защищенный метод

Called for each status message received from the stream.
protected onStatus ( string $type, array $info = [] ) : void
$type string The status type.
$info array The data received along with the status message.
Результат void

onStop() защищенный метод

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.
protected onStop ( string $reason = '' ) : void
$reason string Reason why the stream was stopped
Результат void

onStopped() защищенный метод

This is called when the consumer is stopped.
protected onStopped ( string $reason = '' ) : void
$reason string Reason to stop the stream
Результат void

onWarning() защищенный метод

This is called when a warning notification is received on a scream connection.
protected onWarning ( string $message ) : void
$message string The warning message
Результат void

stop() публичный метод

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
Результат void

Описание свойств

$_auto_reconnect защищенное свойство

Set to true when the client is supposed to reconnect automatically.
protected $_auto_reconnect

$_definition защищенное свойство

The DataSift stream definition object.
protected $_definition

$_eventHandler защищенное свойство

The event handler object.
protected $_eventHandler

$_hashes защищенное свойство

The array of hashes to be consumed if using multi
protected $_hashes

$_is_multi защищенное свойство

True if this is consuming multiple hashes
protected $_is_multi

$_state защищенное свойство

State active or stopped.
protected $_state

$_user защищенное свойство

DataSift object
protected $_user