interactive-solutions / zf-hermes
该包的最新版本(0.0.1)没有提供许可证信息。
Node Hermes 的交互式解决方案扩展
0.0.1
2016-03-26 15:42 UTC
Requires
- php: >=7.0.0
- container-interop/container-interop: ^1.1
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is auto-updated.
Last update: 2024-09-05 03:38:49 UTC
README
用于与 Node-Hermes 一起工作的 Zend Framework 模块。
配置
将 hermes.global.php.dist
复制到要更改默认 Redis 配置。默认值是
host = 'localhost'
port = 6379
用法
只需注入 NotifierService
并使用 publish 通过 Redis 发送消息。
// $this->notifierService is an injected NotifierService $this->notifierService->publish($message);
$message
必须是一个实现了 MessageInterface
的对象。
消息接口包含以下属性
channel
发布消息到 Redis 通道userId
触发 Redis 事件的用户 IDtimeStamp
消息创建的时间戳payload
需要发送的附加数据
通知服务将包含属性 userId
、timeStamp
和 payload
的 json 编码消息发送到 Redis 通道 channel
。
注意,通道属性不是消息的一部分。
建议
建议使用监听器监听应生成 Redis 消息的事件。虽然可以将通知服务直接注入到另一个类中。