This commit is contained in:
2025-12-01 06:39:05 +08:00
parent 2e54326aba
commit d6c8380c64
2 changed files with 135 additions and 63 deletions
+37 -19
View File
@@ -14,33 +14,50 @@
</style>
</head>
<body style="background-color: #666;color: #fff;presentation-level: increment;">
<video id="output" width="320" height="240" autoplay></video>
<!--<video id="output" width="320" height="240" autoplay></video>-->
<pre id="format"></pre>
<script type="text/javascript">
let sock, tick, format = document.getElementById('format');
let buffer;
let ms = new MediaSource()
let output = document.getElementById('output')
output.src = URL.createObjectURL(ms)
ms.onsourceopen = () => {
buffer = ms.addSourceBuffer('video/webm; codecs="vorbis,vp8"')
}
// let buffer;
// let ms = new MediaSource()
let unique = '';
// let output = document.getElementById('output')
// output.src = URL.createObjectURL(ms)
// ms.onsourceopen = () => {
// buffer = ms.addSourceBuffer('video/webm; codecs="vorbis,vp8"')
// }
function message(message) {
// let div = document.createElement('div');
// div.innerHTML = message.data;
// div.style.cssText = 'padding:5px 10px;background-color:#222;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;word-break: break-all;word-wrap: break-word;';
// div.style.marginBottom = '10px';
// let count = format.getElementsByTagName('div');
try {
let data = JSON.parse(message.data);
if (data.event === 'user::kick') {
return;
}
if (unique === '') {
unique = message.data;
}
if (data["ack"]) {
sock.send(JSON.stringify({'event': 'ack', 'id': unique, 'data': {'ack': data["ack"]}}));
}
} catch (e) {
if (unique === '') {
unique = message.data;
}
}
let div = document.createElement('div');
div.innerHTML = message.data;
div.style.cssText = 'padding:5px 10px;background-color:#222;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;word-break: break-all;word-wrap: break-word;';
div.style.marginBottom = '10px';
let count = format.getElementsByTagName('div');
buffer.appendBuffer(new Uint8Array(message.data))
// format.insertBefore(div, count[0]);
format.insertBefore(div, count[0]);
}
function close(even) {
unique = '';
setTimeout(function () {
connect();
sock.onmessage = message;
@@ -50,13 +67,14 @@
}
function connect() {
sock = new WebSocket('wss://center-wss.stupideyes.com/ws?access_token=6648f48a-466ba-6394-70527ef8b-bc47b8');
sock.onopen = function () {
sock = new WebSocket('wss://center-wss.stupideyes.com/ws?access_token=a8exu0la-77ecu-ijhk-inkgt6vln-rlwwuk');
// sock = new WebSocket('wss://meet-bottle.zhuangb123.com/socket/?auth=dG9rZW49M2I2ODJhNzg0NS0xMTktMzBiMS1mMDkxOGRhNjktNTg2ZDEyJnRpbWU9MTc1MzA4MTI5MyZyZWZyZXNoPXBDT0VFYk9KOG8xTEVZQytyUkR4VlZIaXR1TmVWcndCY2crRTBua2U1ZkJuUWNJaHl6NUtTV0x2ZExXa1Y5aXlyK3NmRnRwOVRCVU91MnhPSVRPRjROTjhoT0hlODNNVmZjN1NXb2QyeDY0TXEvZTFEUCtySjNzNjZhVlplcXdYV0QzV2VRd0V6YkowZ29oOFFqRHVvZGcyb281OEZkZVp5TjVIcHFyejRZQ0VMbkxydXlCUmpFdjNTWnRsQ3gxMWthNDNxbEwzM1lJYVlaV2t3dEhOMm9VaXllNFpKOHFnU1FueEZ4N0c4RDhabzBhajFFeEJIZTlJUFQ0VUo3UkR0V0g2Y3A3bkY3bXlkVHB4Wnp5NG1kRlgxa3M5eC9iVlJHaVFDRnU4VEFsUVdDdHEzbmJ1TnNYZVd3Q2dXWEd1OEUzMld3THVFRzRCZFRCanA2MGtYUT09');
sock.onopen = function (data) {
if (tick) {
clearInterval(tick)
}
tick = setInterval(function () {
sock.send(JSON.stringify({'route': 'getUserPosition', 'tick': new Date().getTime()}));
sock.send(JSON.stringify({'event': 'tick', 'id': unique, 'data': {'math': Math.ceil(Math.random() * 1000000)}}));
}, 3000)
}
}
+96 -42
View File
@@ -1,51 +1,105 @@
<?php
ini_set('memory_limit','64GB');
use wchat\common\AppConfig;
use wchat\wx\V3\Libs\TransferDetail;
use wchat\wx\V3\Libs\TransferSceneReportInfo;
use wchat\wx\V3\WxV3Transfer;
use Swoole\Coroutine;
use Swoole\Coroutine\Http\Client;
use function Swoole\Coroutine\run;
//ini_set('memory_limit', '64G');
function faker($page = 0)
{
$client = new Client('openapi.stupideyes.com', 443, true);
$client->get('/faker?offset=' . $page);
$client->close();
$msg = 'default';
try {
return json_decode($client->getBody(), true);
if (random_int(1, 10) % 3 === 0) {
return;
}
$msg = 'default2';
} catch (\Exception $e) {
} finally {
var_dump($msg);
}
run(function () {
$offset = 1;
$success = 0;
for ($i = 1; $i <= 10000; $i++) {
$faker = faker($offset);
$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');
// var_dump($socket->recv());
Coroutine::sleep(0.1);
}
} else {
$success -= 1;
echo 'websocket fail: ' . socket_strerror($socket->errCode) . PHP_EOL;
}
});
Coroutine::sleep(0.1);
var_dump($success);
}
//run(function () {
// $offset = 1;
// $success = 0;
//
// $group = new Coroutine\WaitGroup();
// for ($i = 0; $i < 54500; $i++) {
// $offset++;
//
// $group->add(1);
// Swoole\Coroutine::create(function () use ($offset, &$success) {
// $socket = new Swoole\Coroutine\Http\Client('192.168.0.57', 14101);
// $socket->upgrade("/websocket");
// if ($socket->connected) {
// $success += 1;
// while (true) {
// $socket->recv();
// Coroutine::sleep(0.1);
//
// $socket->push("2");
// }
// } else {
// echo 'websocket fail: ' . socket_strerror($socket->errCode) . PHP_EOL;
// echo $success;
// }
// # echo $offset . PHP_EOL;
// });
// }
// $group->wait();
//});
//
//
//function Index_Odd()
//{
//
//}
});
//class Dispatcher
//{
//
//
// public function dispatch(){
//
// }
//
//
// public static function dispatch1()
// {
//
// }
//
//
//}
//$t = microtime(true);
//var_dump(method_exists('Dispatcher', 'dispatch'));
//var_dump(method_exists('Dispatcher', 'dispatch1'));
//
//var_dump(microtime(true) - $t);
//
//$t = microtime(true);
//
//$r = new ReflectionClass('Dispatcher');
//
//var_dump($r->hasMethod('dispatch'));
//var_dump($r->hasMethod('dispatch1') && $r->getMethod('dispatch1')->isStatic());
//
//var_dump(microtime(true) - $t);
//$transferDetail = new TransferDetail();
//$transferDetail->setTransferAmount(1);
//$transferDetail->setTransferRemark("提现");
//$transferDetail->setTransferSceneId("1005");
//$transferDetail->setOpenid("xxxxx");
//$transferDetail->setNotifyUrl("https");
//$transferDetail->setOutBillNo("");
//$transferDetail->setTransferSceneReportInfos(new TransferSceneReportInfo('', ''), new TransferSceneReportInfo('', ''));
//$transferDetail->setUserName("");
//$transferDetail->setUserRecvPerception("");
//
//$transfer = new WxV3Transfer();
//$transfer->setPayConfig(AppConfig::instance((object)[]));
//$response = $transfer->transfer($transferDetail);