Channel Distributed Communication Component
(Requires Workerman version >= 3.3.0)
Source code: https://github.com/walkor/Channel
Channel is a distributed communication component designed for inter-process or inter-server communication.
Features
-
Based on the publish-subscribe model
-
Non-blocking IO
Principles
Channel consists of Channel/Server (server side) and Channel/Client (client side).
Channel/Client connects to Channel/Server via the connect interface and maintains a long connection.
Channel/Client uses the on interface to inform Channel/Server about which events it is interested in and registers event callback functions (the callbacks occur in the process where Channel/Client is located).
Channel/Client publishes an event and related data to Channel/Server through the publish interface.
Upon receiving the event and data, Channel/Server will distribute it to Channel/Clients that are interested in the event.
Channel/Client triggers the callback set by the on interface upon receiving the event and data.
Channel/Client will only receive events it is interested in and trigger the corresponding callbacks.
Installation
composer require workerman/channel
Note
Channel can only be used in the Workerman environment and cannot be used in a php-fpm environment.