OpenSwoole\Server->on('PipeMessage', fn)

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Server->on('PipeMessage', Callable $callback)

Parameters

event

The event callback name.

callback

Callable event function.

Return

success

If success, it returns true, otherwise it returns false.

Description

Execute the callback function when the Server is receiving the message sent by sendMessage.

The callback function registered on the event PipeMessage is executed in the Worker Process which is receiving data when using $server->sendMessage(). Both worker and task worker processes are able to trigger this PipeMessage event.

Example

<?php
$server->on('PipeMessage', function(OpenSwoole\Server $server, int $fromWorkerId, mixed $message)
{
  // ...
});
  • $fromWorkerId The ID number of worker where the message is from
  • $message the message that has been received
Last updated on September 1, 2022