1. Go to this page and download the library: Download reactphp-x/bridge library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reactphp-x / bridge example snippets
use ReactphpX\Bridge\Server;
use ReactphpX\Bridge\Pool;
use ReactphpX\Bridge\Verify\VerifyUuid;
use ReactphpX\Bridge\Http\HttpBridge;
use ReactphpX\Bridge\WebSocket\WsBridge;
use ReactphpX\Bridge\Tcp\TcpBridge;
use ReactphpX\Bridge\BridgeStrategy;
use ReactphpX\Bridge\Io\Tcp;
Server::$debug = true;
$server = new Server(new VerifyUuid([
'8d24e2ba-c6f8-4bb6-8838-cacd37f64165' => '10.10.10.1',//value 是自定义的标识符,可以是空
'c4b34f0d-44fa-4ef5-9d28-ccef218d74fb' => '10.10.10.2',
'41c5ee60-0628-4b11-9439-a10ba19cbcdd' => '10.10.10.3'
]));
$pool = new Pool($server, [
'max_connections' => 20,
'connection_timeout' => 2,
'keep_alive' => 5,
'wait_timeout' => 3
]);
new Tcp('0.0.0.0:' . ($argv[1] ?? '8010'), new BridgeStrategy([
new TcpBridge($server),
new HttpBridge(new WsBridge($server))
]));
return $pool;