eee
This commit is contained in:
@@ -17,13 +17,17 @@ function faker($page = 0)
|
||||
|
||||
run(function () {
|
||||
$offset = 1;
|
||||
|
||||
$success = 0;
|
||||
for ($i = 1; $i <= 10000; $i++) {
|
||||
$faker = faker($offset);
|
||||
$offset++;
|
||||
go(function () use ($faker, $offset) {
|
||||
go(function () use ($faker, $offset, &$success) {
|
||||
$socket = new Swoole\Coroutine\Http\Client('43.248.128.57', 14101);
|
||||
$socket->upgrade("/ws?access_token=" . $faker['params']['token']);
|
||||
if ($socket->connected) {
|
||||
$success += 1;
|
||||
|
||||
while (true) {
|
||||
$socket->recv();
|
||||
// $socket->push('hello');
|
||||
@@ -32,13 +36,15 @@ run(function () {
|
||||
Coroutine::sleep(0.1);
|
||||
}
|
||||
} else {
|
||||
$success -= 1;
|
||||
|
||||
echo 'websocket fail: ' . socket_strerror($socket->errCode) . PHP_EOL;
|
||||
}
|
||||
});
|
||||
|
||||
Coroutine::sleep(0.1);
|
||||
|
||||
var_dump($offset);
|
||||
var_dump($success);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user