PHP Class Gui\Ipc\Receiver

This class is used to receive communication messages
Since: 0.1
Author: Gabriel Couto @gabrielrcouto
Afficher le fichier Open project: gabrielrcouto/php-gui Class Usage Examples

Méthodes publiques

Свойство Type Description
$application gui\Application The application object
$messageCallbacks array Array of callbacks

Protected Properties

Свойство Type Description
$buffer string The buffer of received messages
$isWaitingMessage boolean Defines if is waiting message
$parseMessagesBuffer array Array of messages in buffer
$waitingMessageId integer The id of the waitingMessage
$waitingMessageResult mixed The return of the waitingMessage

Méthodes publiques

Méthode Description
__construct ( Application $application ) : void The constructor
addMessageCallback ( integer $id, callable $callback ) : void When the result of a message arrives, we call a callback
callMessageCallback ( integer $id, string | Array | Object | integer $result ) : void Result received, time to call the message callback
callObjectEventListener ( integer $id, string $eventName ) : void Fire a event on a object
onData ( string $data ) : void Process Stdout handler
tick ( ) : void Read the stdout pipe from Lazarus process. This function uses stream_select to be non blocking
waitMessage ( Stream $stdout, MessageInterface $message ) : mixed Wait a message result

Méthodes protégées

Méthode Description
jsonDecode ( string $json ) : MessageInterface | void Decode a received message
parseDebug ( $message ) : void Parse a debug message
parseNormal ( $message ) : void Parse a normal message, can be a command, command result or an event
prepareOutput ( string $string ) : String Construct the output string

Method Details

__construct() public méthode

The constructor
public __construct ( Application $application ) : void
$application gui\Application
Résultat void

addMessageCallback() public méthode

When the result of a message arrives, we call a callback
public addMessageCallback ( integer $id, callable $callback ) : void
$id integer Message ID
$callback callable Callback function
Résultat void

callMessageCallback() public méthode

Result received, time to call the message callback
public callMessageCallback ( integer $id, string | Array | Object | integer $result ) : void
$id integer Message ID
$result string | Array | Object | integer Command Result
Résultat void

callObjectEventListener() public méthode

Fire a event on a object
public callObjectEventListener ( integer $id, string $eventName ) : void
$id integer Object ID
$eventName string Event Name
Résultat void

jsonDecode() protected méthode

Decode a received message
protected jsonDecode ( string $json ) : MessageInterface | void
$json string Received json message
Résultat MessageInterface | void

onData() public méthode

Process Stdout handler
public onData ( string $data ) : void
$data string Data received
Résultat void

parseDebug() protected méthode

Parse a debug message
protected parseDebug ( $message ) : void
$message Message
Résultat void

parseNormal() protected méthode

Parse a normal message, can be a command, command result or an event
protected parseNormal ( $message ) : void
$message Message
Résultat void

prepareOutput() protected méthode

Construct the output string
protected prepareOutput ( string $string ) : String
$string string Output string
Résultat String New output string

tick() public méthode

Read the stdout pipe from Lazarus process. This function uses stream_select to be non blocking
public tick ( ) : void
Résultat void

waitMessage() public méthode

Wait a message result
public waitMessage ( Stream $stdout, MessageInterface $message ) : mixed
$stdout React\Stream\Stream Stdout Stream
$message MessageInterface Command waiting result
Résultat mixed The result

Property Details

$application public_oe property

The application object
public Application,Gui $application
Résultat gui\Application

$buffer protected_oe property

The buffer of received messages
protected string $buffer
Résultat string

$isWaitingMessage protected_oe property

Defines if is waiting message
protected bool $isWaitingMessage
Résultat boolean

$messageCallbacks public_oe property

Array of callbacks
public array $messageCallbacks
Résultat array

$parseMessagesBuffer protected_oe property

Array of messages in buffer
protected array $parseMessagesBuffer
Résultat array

$waitingMessageId protected_oe property

The id of the waitingMessage
protected int $waitingMessageId
Résultat integer

$waitingMessageResult protected_oe property

The return of the waitingMessage
protected mixed $waitingMessageResult
Résultat mixed