octamp/client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

octamp/client

最新稳定版本:v1.3.0

Composer 安装命令:

composer require octamp/client

包简介

WAMP client for PHP Swoole

README 文档

README

Packagist PHP Version License Test codecov

Octamp Client is an open source client for WAMP (Web Application Messaging Protocol), for PHP.

Octamp Client uses Open Swoole, is a high-performance network framework based on an event-driven, asynchronous, non-blocking I/O coroutine programming model for PHP.

We also design the Octamp Client functions to be identical to AutobahnJS

The name Octamp is from Octopus + WAMP

Supported WAMP Features

  • Publish
  • Subscribe
  • Call
  • Call Progressive
  • Register

Requierements

  • PHP >= 8.1
  • Swoole / OpenSwoole Extension

Installation

composer require octamp/client

Example

<?php

use Octamp\Client\Auth\WampcraAuthenticator;
use Octamp\Client\Peer;
use Octamp\Client\Session;

require_once __DIR__ . '/../../vendor/autoload.php';

\Co\run(function () {
    $client = new Peer('crossbar', 9000);
    
    $client->onOpen(function (Session $session) {
        // subscribe
        $session->subscribe('hello', function (array $args) {
            echo 'Event ' . $args[0] . PHP_EOL;
        });
    
        // publish
        $session->publish('hello', ['hello octamp'], [], ['exclude_me' => false]);
    
        // publish with acknowledgement
        $session
            ->publish('hello', ['hello octamp with acknowledgement'], [], ['acknowledge' => true, 'exclude_me' => false])
            ->then(
                function () {
                    echo 'Publish Acknowledged!' . PHP_EOL;
                },
                function ($error) {
                    echo 'Publish Error ' . $error . PHP_EOL;
                },
            );
    
        // register
        $session->register('add', function (array $args) {
            return $args[0] + $args[1];
        });
    
        // call
        $session->call('add', [1, 3])->then(function ($result) {
            echo 'Result ' . $result . PHP_EOL;
        });
    });
    
    $client->open();
});

TODOs

  • Call Cancel
  • Call Timeout
  • Unsubscribe
  • RPC Progress Call
  • Auto Reconnect
  • Subprotocol Handling
  • Heartbeat
  • Custom Error Handling
  • TLS connection
  • Session Logging
  • Session Prefix
  • Pattern Base Subscription / Registration

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-02-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固