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

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

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
Last updated on August 31, 2022