chore: 重写初始提交(清空历史,整理后全量提交)

This commit is contained in:
ywxapp
2026-08-16 16:54:14 +08:00
commit 6c1a106bc1
1808 changed files with 238144 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
// app/Protocols/ProtobufProtocol.php
namespace addon\wxchat\Protocols;
/**
* ProtobufProtocol 类
*
* @author ywxapp <admin@ywxapp.cn>
*/
class ProtobufProtocol
{
public static function input($recv_buffer, $connection) {
if (strlen($recv_buffer) < 4) return 0;
$len = unpack('N', substr($recv_buffer, 0, 4))[1]; // 大端序4字节长度头
return $len + 4; // 返回本次包完整长度
}
public static function decode($recv_buffer, $connection) {
return substr($recv_buffer, 4); // 剥离长度头,返回纯Protobuf字节流
}
public static function encode($data, $connection) {
return pack('N', strlen($data)) . $data; // 添加4字节长度头
}
}