Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cydrickn/thruway-swoole-transport
OpenSwoole / Swoole Websocket Transport for Thruway Router
https://github.com/cydrickn/thruway-swoole-transport
openswoole swoole thruway transport wamp-protocol wamp-router wamp-server websocket
Last synced: about 1 month ago
JSON representation
OpenSwoole / Swoole Websocket Transport for Thruway Router
- Host: GitHub
- URL: https://github.com/cydrickn/thruway-swoole-transport
- Owner: cydrickn
- License: mit
- Created: 2023-09-23T03:25:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-06T11:28:33.000Z (about 1 year ago)
- Last Synced: 2024-04-10T05:20:44.727Z (9 months ago)
- Topics: openswoole, swoole, thruway, transport, wamp-protocol, wamp-router, wamp-server, websocket
- Language: PHP
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Swoole Thruway Transport
OpenSwoole / Swoole Websocket Transport for Thruway Router
## Prerequisite:
- PHP version >= 8.1
- [OpenSwoole](https://openswoole.com/docs/get-started/installation)
- [voryx/thruway](https://github.com/voryx/Thruway)## Installation
```sh
composer require cydrickn/thruway-swoole-transport
```## Example
### Ouside the worker start
```php
addTransportProvider($transportProvider);$server->addListener(WebsocketServer::EVENT_SERVER_START, function () use($transportProvider, $server) {
\Thruway\Logging\Logger::info($transportProvider, 'Websocket listening on 0.0.0.0:9000');
$server->shutdown();
});$router->start(false);
```### Inside Worker Start
```php
addListener(WebsocketServer::EVENT_SERVER_START, function () {
\Thruway\Logging\Logger::info(null, 'Websocket listening on 0.0.0.0:9000');
});$server->addListener(WebsocketServer::EVENT_WORKER_START, function () use($server) {
$transportProvider = new SwooleTransportProvider($server);$router = new Router(new SwooleLoop());
$router->addTransportProvider($transportProvider);$router->start(false);
});
```