Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/linux-china/rsocket-php
RSocket PHP SDK
https://github.com/linux-china/rsocket-php
php reactphp rsocket
Last synced: 14 days ago
JSON representation
RSocket PHP SDK
- Host: GitHub
- URL: https://github.com/linux-china/rsocket-php
- Owner: linux-china
- License: apache-2.0
- Created: 2020-07-15T16:57:09.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-27T21:09:44.000Z (over 3 years ago)
- Last Synced: 2024-12-24T23:43:45.672Z (15 days ago)
- Topics: php, reactphp, rsocket
- Language: PHP
- Homepage:
- Size: 90.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RSocket PHP
================
[![Composer](https://img.shields.io/packagist/v/rsocket/rsocket-php)](https://packagist.org/packages/rsocket/rsocket-php)RSocket PHP SDK based on ReactPHP and RxPHP.
# Requirements
* PHP 7.4.x
# Examples
### RSocket Client
```php
Scheduler::setDefaultFactory(function () use ($loop) {
return new Scheduler\EventLoopScheduler($loop);
});$rsocketPromise = RSocketConnector::create($loop)->connect("tcp://127.0.0.1:42252");
$rsocketPromise->then(function (RSocket $rsocket) {
$observablePayload = $rsocket->requestResponse(Payload::fromText("text/plain", "Ping"));
$observablePayload->subscribe(
function (Payload $x) {
echo 'Result: ' . $x->getDataUtf8();
}
);
});
```### RSocket Server
```php
Scheduler::setDefaultFactory(function () use ($loop) {
return new Scheduler\EventLoopScheduler($loop);
});$listenUri = "tcp://127.0.0.1:42252";
$socketAcceptor = CallableSocketAcceptor::handle(function ($setupPayload, $sendingRSocket) {
return AbstractRSocket::requestResponseHandler(function ($payload) {
return Observable::of(Payload::fromText("metadata", "PONG"));
});
});
$server = RSocketServer::create($loop, $socketAcceptor)->bind($listenUri);
print("RSocket Server started on ${listenUri}");
```# RSocket Service stub and routing
Please check https://github.com/rsocket/rsocket-php/tree/master/tests/route
# RSocket
- Operations
- [x] REQUEST_FNF
- [x] REQUEST_RESPONSE
- [x] REQUEST_STREAM
- [ ] REQUEST_CHANNEL
- [x] METADATA_PUSH
- More Operations
- [x] Error
- [ ] Cancel
- [x] Keepalive
- QoS
- [ ] RequestN
- [ ] Lease
- Transport
- [x] TCP
- [x] Websocket
- High Level APIs
- [x] Client
- [x] Server
- Misc
- [x] RxPHP# References
* RSocket: https://rsocket.io
* ReactPHP: https://github.com/reactphp/reactphp
* ReactPHP Projects: https://github.com/reactphp/reactphp/wiki/Users
* RxPHP: https://github.com/ReactiveX/RxPHP
* New .phpstorm.meta.php features: https://blog.jetbrains.com/phpstorm/2019/02/new-phpstorm-meta-php-features/
* PHP Reactive Programming: https://www.packtpub.com/web-development/php-reactive-programming
* Ratchet: Asynchronous WebSocket server https://github.com/ratchetphp/Ratchet
* Pawl: asynchronous WebSocket client https://github.com/ratchetphp/Pawl
* PHP 8: Attributes: https://stitcher.io/blog/attributes-in-php-8