PHPackages                             friendsofhyperf/ipc-broadcaster - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. friendsofhyperf/ipc-broadcaster

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

friendsofhyperf/ipc-broadcaster
===============================

IPC broadcaster component for Hyperf.

v3.2.1(3w ago)02.3k↑22.9%3MITPHP

Since Nov 26Pushed 2w ago3 watchersCompare

[ Source](https://github.com/friendsofhyperf/ipc-broadcaster)[ Packagist](https://packagist.org/packages/friendsofhyperf/ipc-broadcaster)[ Fund](https://hdj.me/sponsors/)[ GitHub Sponsors](https://github.com/huangdijia)[ RSS](/packages/friendsofhyperf-ipc-broadcaster/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (2)Versions (16)Used By (3)

Ipc Broadcaster
===============

[](#ipc-broadcaster)

[中文说明](README_CN.md)

Broadcast serializable messages between Hyperf server workers and user processes.

Installation
------------

[](#installation)

```
composer require friendsofhyperf/ipc-broadcaster
```

The package automatically registers its `ConfigProvider`. It binds `BroadcasterInterface` to `AllProcessesBroadcaster` and registers the listeners required to receive messages in server workers. There is no configuration file to publish.

The package declares `hyperf/event ~3.2.0` and no optional dependencies in its `composer.json`. Use it in a Hyperf server application that provides the server, process, container, and DI runtime classes used by the broadcasters.

Broadcast Messages
------------------

[](#broadcast-messages)

The `broadcast()` function accepts an `IpcMessageInterface` instance or a closure. By default, it uses `AllProcessesBroadcaster` to send the message to all other server workers and all registered coroutine user processes.

### Class Message

[](#class-message)

Extend `IpcMessage` and implement `handle()`. `IpcMessage` also provides `getFromWorkerId()` and `setFromWorkerId()` through `InteractsWithFromWorkerId`. When a server worker receives the message, `getFromWorkerId()` contains the sending worker ID.

```
