valeriitropin/socketio-redis-adapter
Composer 安装命令:
composer require valeriitropin/socketio-redis-adapter
包简介
关键字:
README 文档
README
Partial port of socket.io redis adapter, async, allows to get clients/rooms and to manage them. The main goal of this project is possibility to communicate between php and socket.io applications. Built on top of ReactPHP components.
Installation
composer require valeriitropin/socketio-redis-adapter
How to use
use React\EventLoop\Factory as ReactFactory; use ValeriiTropin\Socketio\RedisAdapter; use Clue\React\Block; use React\Promise; $loop = ReactFactory::create(); $client = new RedisAdapter($loop); $promise = $client->allRooms()->then(function ($rooms) use ($client) { $promises = []; foreach ($rooms as $room) { $promises[] = $client->clients([$room])->then(function ($clients) use ($room) { foreach ($clients as $client) { echo $room . ' ' . $client . "\n"; } }); } return Promise\all($promises); })->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; }); Block\await($promise, $loop);
API
RedisAdapter
__construct(React\EventLoop\LoopInterface $loop, $options = [])
$options:
prefix: pub/sub events prefix (socket.io)requestsTimeout: timeout in milliseconds, float (5)namespace: socket.io namespace (/)pubClient: pub clientsubClient: pub clientcustomHook: callableuri: Redis connection string, see docs (localhost)
clients($rooms = []): React\Promise\Promise
Returns the list of client IDs connected to rooms across all nodes.
$adapter->clients($rooms) ->then(function ($clients) { var_dump($clients); }) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
clientRooms($id): React\Promise\Promise
Returns the list of rooms the client with the given ID has joined (even on another node).
$adapter->clients($id) ->then(function ($rooms) { var_dump($rooms); }) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
allRooms(): React\Promise\Promise
Returns the list of all rooms from all nodes.
$adapter->allRooms() ->then(function ($allRooms) { var_dump($allRooms); }) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
remoteJoin($id, $room): React\Promise\Promise
$adapter->remoteJoin($id, $room) ->then(function () {}) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
remoteLeave($id, $room): React\Promise\Promise
$adapter->remoteLeave($id, $room) ->then(function () {}) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
remoteDisconnect($id, $close): React\Promise\Promise
$adapter->remoteDisconnect($id, $close) ->then(function () {}) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
customRequest($data): React\Promise\Promise
Sends a request to every nodes, that will respond through the customHook method.
$adapter->customRequest($data) ->then(function ($replies) {}) ->otherwise(function ($error) { echo ($error->getMessage()) . "\n"; });
getLoop(): React\EventLoop\LoopInterface
Returns loop instance.
getPub(): Clue\React\Redis\StreamingClient
Returns pub client.
getSub(): Clue\React\Redis\StreamingClient
Returns sub client.
unsubscribeFromRequestChannel(): React\Promise\Promise
Unsubscribes the adapter instance from request channel.
Links
valeriitropin/socketio-redis-adapter 适用场景与选型建议
valeriitropin/socketio-redis-adapter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「redis」 「adapter」 「Socket.io」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 valeriitropin/socketio-redis-adapter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 valeriitropin/socketio-redis-adapter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 valeriitropin/socketio-redis-adapter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Adapter designed to add Framework Agnosticism for Caching within PHP Packages.
flysystem cache Adapter
Virtual Filesystem Storage Adapter for Laravel
Microservice RPC through message queues.
The CodeIgniter Redis package
A simple interface for composite Flysystem adapters
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-18