Init Repo

This commit is contained in:
root
2019-09-06 23:53:10 +08:00
commit f0ef89dfbb
7905 changed files with 914138 additions and 0 deletions

View File

@ -0,0 +1,42 @@
<?php
// Cannot destroy active lambda swoole_function
// 先用nc起一个 swoole_server
// nc -4lk 9090
send("hello", function($cli, $data) {
var_dump($data);
send("hello", function($cli, $data) {
var_dump($data);
send("hello", function($cli, $data) {
var_dump($data);
});
});
});
function send($str, $onRecv)
{
static $client;
if ($client === null) {
$client = new \swoole_client(SWOOLE_SOCK_TCP, SWOOLE_SOCK_ASYNC);
$client->on("error", function($cli) { echo "error"; });
$client->on("close", function($cli) { echo "close"; });
$client->on("connect", function($cli) use($str, $onRecv) {
send($str, $onRecv);
});
}
// !!! Fatal error: Cannot destroy active lambda swoole_function
$client->on("receive", $onRecv);
if ($client->isConnected()) {
$client->send("PING");
} else {
$client->connect("127.0.0.1", 9090);
}
}