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

Declaration

<?php
Swoole\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(Swoole\Server $server, int $fromWorkerId, mixed $message)
{
  // ...
});
  • $fromWorkerId The ID number of worker where the message is from
  • $message the message that has been received