Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cydrickn/octamp-client
WAMP Client for PHP Swoole
https://github.com/cydrickn/octamp-client
autobahn openswoole php php8 pubsub real-time rpc swoole wamp wamp-client wamp-protocol websocket
Last synced: 21 days ago
JSON representation
WAMP Client for PHP Swoole
- Host: GitHub
- URL: https://github.com/cydrickn/octamp-client
- Owner: cydrickn
- License: mit
- Created: 2023-01-29T13:23:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-15T03:57:33.000Z (about 1 year ago)
- Last Synced: 2024-09-30T18:10:48.687Z (about 1 month ago)
- Topics: autobahn, openswoole, php, php8, pubsub, real-time, rpc, swoole, wamp, wamp-client, wamp-protocol, websocket
- Language: PHP
- Homepage:
- Size: 338 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Octamp Client
[![Packagist PHP Version](https://img.shields.io/packagist/dependency-v/octamp/client/php?style=flat-square)](https://packagist.org/packages/octamp/client)
[![License](https://img.shields.io/packagist/l/octamp/client?style=flat-square)](/LICENSE)
[![Test](https://github.com/cydrickn/octamp-client/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/cydrickn/octamp-client/actions/workflows/test.yml)
[![codecov](https://codecov.io/github/cydrickn/octamp-client/branch/main/graph/badge.svg?token=8Y8BNJE1VG)](https://codecov.io/github/cydrickn/octamp-client)Octamp Client is an open source client for [WAMP (Web Application Messaging Protocol)](https://wamp-proto.org/), for PHP.
Octamp Client uses [Open Swoole](https://openswoole.com/docs), 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](https://github.com/crossbario/autobahn-js)
The name Octamp is from Octopus + WAMP
## Supported WAMP Features
- Publish
- Subscribe
- Call
- Call Progressive
- Register## Requierements
- PHP >= 8.1
- Swoole / OpenSwoole Extension## Installation
```sh
composer require octamp/client
```## Example
```php
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