承接 kanata-php/conveyor-server-client 相关项目开发

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

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

kanata-php/conveyor-server-client

Composer 安装命令:

composer require kanata-php/conveyor-server-client

包简介

Server-Side WebSocket Client ready for Socket Conveyor

README 文档

README

Tests

A server-side client for the php package kanata-php/socket-conveyor

Prerequisites

Install

composer require kanata-php/conveyor-server-client

Description

This is a server-side client for the Socket Conveyor PHP package.

Usage

Once installed, the following example shows how it works to use this package.

use Kanata\ConveyorServerClient\Client;

$options = [
    'onMessageCallback' => function(Client $currentClient, string $message) {
        echo 'Message received: ' . $message . PHP_EOL;
    },
];

$client = new Client($options);
$client->connect();

With the previous example you'll have a PHP script connected and waiting for messages to come. For each message received there will be a printed message in the terminal executing this script. This client will try to connect to ws://127.0.0.1:8000. To understand more Socket Conveyor channel and listeners you can head to its documentation.

Important: this example doesn't have timeout. This means it will be running until its process gets killed. If you just need to listen for a limited time, or need a timeout for any other reason, use the timeout option.

This package has the following options (showing its respective defaults):

[
    /**
     * @var string
     */
    'protocol' => 'ws',
    
    /**
     * @var string
     */
    'uri' => '127.0.0.1',
    
    /**
     * @var int
     */
    'port' => 8000,
    
    /**
     * @var string
     */
    'query' => '',
    
    /**
     * @var ?string
     */
    'channel' =>  null,
    
    /**
     * @var ?string
     */
    'listen' => null,
    
    /**
     * @var ?callable
     */
    'onOpenCallback' => null,
    
    /**
     * @var ?callable
     */
    'onReadyCallback' => null,
    
    /**
     * Callback for incoming messages.
     * Passed parameters:
     *   - \WebSocket\Client $client
     *   - string $message
     *
     * @var ?callable
     */
    'onMessageCallback' => null,
    
    /**
     * Callback for disconnection.
     * Passed parameters:
     *   - \WebSocket\Client $client
     *   - int $reconnectionAttemptsCount
     *
     * @var ?callable
     */
    'onDisconnectCallback' => null,
    
    /**
     * Callback for Reconnection moment.
     * Passed parameters:
     *   - \WebSocket\Client $client
     *   - int \Throwable $e
     *
     * @var ?callable
     */
    'onReconnectionCallback' => null,
    
    /**
     * When positive, considered in seconds
     *
     * @var int
     */
    'timeout' => -1,
    
    /**
     * @var bool
     */
    'reconnect' => false;
    
    /**
     * Number of attempts if disconnects
     * For this to keeps trying forever, set it to -1. 
     *
     * @var int
     */
    'reconnectionAttempts' => = 0;
    
    /**
     * Interval to reconnect in seconds 
     * 
     * @var int 
     */
    'reconnectionInterval' => = 2;
]

This is this package's Conveyor Client interface:

namespace Kanata\ConveyorServerClient;

use WebSocket\Client;

interface ClientInterface
{
    public function connect(): void;
    public function getClient(): ?Client;
    public function close(): void;
    public function send(string $message): void;
    public function sendRaw(string $message): void;
}

Author

👤 Savio Resende

📝 License

Copyright © 2022 Savio Resende.

kanata-php/conveyor-server-client 适用场景与选型建议

kanata-php/conveyor-server-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 197 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 09 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 kanata-php/conveyor-server-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 kanata-php/conveyor-server-client 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 197
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 16
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-25