cursedcoder / emessenger
通过协议发送消息到PHP进程。
0.1
2016-04-13 05:06 UTC
Requires
- php: >=5.6
- concerto/comms: ~0.8
- cursedcoder/universal-serializer: ^0.1.0
- react/react: ~0.4@dev
Requires (Dev)
- phpunit/phpunit: ^5.3
This package is not auto-updated.
Last update: 2024-09-26 00:24:45 UTC
README
发送任何消息到远程进程。
可用的传输方式
- Unix套接字文件(unix://tmp/log.sock)
- 后续更多:tcp, udp等。
示例
<?php // logserver.php use React\EventLoop\Factory as EventLoopFactory; use EMessenger\Transport\UnixTransport; use EMessenger\MessengerFactory; $loop = EventLoopFactory::create(); $transport = new UnixTransport($loop, 'unix://tmp/log.sock'); $messenger = MessengerFactory::server($transport); $messenger->send('debug', 'This is a test message.');
<?php // logwriter.php use React\EventLoop\Factory as EventLoopFactory; use EMessenger\Transport\UnixTransport; use EMessenger\MessengerFactory; $loop = EventLoopFactory::create(); $transport = new UnixTransport($loop, 'unix://tmp/log.sock'); $messenger = MessengerFactory::client($transport); $messenger->on('debug', function($debug) { echo 'Received debug message: ' . $debug; });