PHP Класс Gui\Ipc\Receiver

This class is used to receive communication messages
С версии: 0.1
Автор: Gabriel Couto @gabrielrcouto
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$application gui\Application The application object
$messageCallbacks array Array of callbacks

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

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

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

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

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

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

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

__construct() публичный Метод

The constructor
public __construct ( Application $application ) : void
$application gui\Application
Результат void

addMessageCallback() публичный Метод

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

callMessageCallback() публичный Метод

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

callObjectEventListener() публичный Метод

Fire a event on a object
public callObjectEventListener ( integer $id, string $eventName ) : void
$id integer Object ID
$eventName string Event Name
Результат void

jsonDecode() защищенный Метод

Decode a received message
protected jsonDecode ( string $json ) : MessageInterface | void
$json string Received json message
Результат MessageInterface | void

onData() публичный Метод

Process Stdout handler
public onData ( string $data ) : void
$data string Data received
Результат void

parseDebug() защищенный Метод

Parse a debug message
protected parseDebug ( $message ) : void
$message Message
Результат void

parseNormal() защищенный Метод

Parse a normal message, can be a command, command result or an event
protected parseNormal ( $message ) : void
$message Message
Результат void

prepareOutput() защищенный Метод

Construct the output string
protected prepareOutput ( string $string ) : String
$string string Output string
Результат String New output string

tick() публичный Метод

Read the stdout pipe from Lazarus process. This function uses stream_select to be non blocking
public tick ( ) : void
Результат void

waitMessage() публичный Метод

Wait a message result
public waitMessage ( Stream $stdout, MessageInterface $message ) : mixed
$stdout React\Stream\Stream Stdout Stream
$message MessageInterface Command waiting result
Результат mixed The result

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

$application публичное свойство

The application object
public Application,Gui $application
Результат gui\Application

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

The buffer of received messages
protected string $buffer
Результат string

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

Defines if is waiting message
protected bool $isWaitingMessage
Результат boolean

$messageCallbacks публичное свойство

Array of callbacks
public array $messageCallbacks
Результат array

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

Array of messages in buffer
protected array $parseMessagesBuffer
Результат array

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

The id of the waitingMessage
protected int $waitingMessageId
Результат integer

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

The return of the waitingMessage
protected mixed $waitingMessageResult
Результат mixed