PHP 클래스 DataSift_StreamConsumer

저자: Stuart Dallas ([email protected])
파일 보기 프로젝트 열기: datasift/datasift-php 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_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