承接 valeriitropin/socketio-redis-adapter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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 client
  • subClient: pub client
  • customHook: callable
  • uri: 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 valeriitropin/socketio-redis-adapter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 18
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 11
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-12-18