api-clients / pusher
异步优先的 Pusher 客户端
1.2.0
2019-08-15 09:58 UTC
Requires
- php: ^7.2
- api-clients/command-bus: ^2.0
- clue/block-react: ^1.1
- jean85/pretty-package-versions: ^1.0
- react/dns: ^1.0 || ^0.4.9
- react/http-client: ^0.5 || ^0.4.17
- reactivex/rxphp: ^2.0.4
- rx/helpers: ^1.0
- rx/operator-extras: ^2.1
- rx/websocket: ^2.0 || ^1.0
- voryx/event-loop: ^3.0 || ^2.0.2
Requires (Dev)
- dev-master
- 1.2.0
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.1
- 1.0.0
- dev-renovate/configure
- dev-dependabot/add-v2-config-file
- dev-dependabot/composer/jean85/pretty-package-versions-1.5.1
- dev-event-loop-0.5-3.0
- dev-pretty-verions
- dev-support-rx-websocket-2.x-and-1.x-simultaniously
- dev-improvement-handle-disconnects-and-reconnect-when-appropriate
- dev-ci-appveyor
- dev-change-rxwebsocket-client
This package is auto-updated.
Last update: 2024-09-15 19:07:21 UTC
README
安装
要通过 Composer 安装,请使用以下命令,它将自动检测最新版本并将其与 ^
绑定。
composer require api-clients/pusher
用法
$loop = Factory::create(); $client = AsyncClient::create($loop, 'Application ID here'); // OR when you need to specify the cluster $client = AsyncClient::create($loop, 'Application ID here', null, 'cluster-here'); $client->channel('channel_name')->subscribe( function (Event $event) { // Gets called for each incoming event echo 'Channel: ', $event->getChannel(), PHP_EOL; echo 'Event: ', $event->getEvent(), PHP_EOL; echo 'Data: ', json_encode($event->getData()), PHP_EOL; }, function ($e) { // Gets called on errors echo (string)$e; }, function () { // Gets called when the end of the stream is reached echo 'Done!', PHP_EOL; } ); $loop->run();
更多示例请参阅 示例目录。
特性
本项目旨在在 v1.3
中与 Pusher 的特性 实现完全兼容。
- 订阅频道
- 存在频道
- 身份验证
许可证
MIT 许可证 (MIT)
版权所有 (c) 2017 Cees-Jan Kiewiet
在此特此授予任何获得此软件及其相关文档副本(“软件”)的人免费使用软件的权利,不受任何限制,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本的权利,并允许向获得软件的人提供软件以供其使用,前提是必须遵守以下条件
必须在软件的所有副本或主要部分中包含上述版权声明和本许可声明。
本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定目的的适用性和非侵权性。在任何情况下,作者或版权所有者不对任何索赔、损害或其他责任(无论因合同、侵权或其他原因产生)承担责任,无论该索赔、损害或其他责任是否因软件或其使用或其他方式而产生。