zen-studio/joint-buffer

基于Google Protocol Buffer的Buffer拼装器,可以将两段Buffer进行拼装和拆解

1.0.1 2022-07-08 01:11 UTC

This package is auto-updated.

Last update: 2024-11-07 21:50:31 UTC


README

composer require zen-studio/joint-buffer

使用方法

对二进制流拆解

list($cmd_buffer, $data_buffer) = make(IJointBuffer::class)->unPack($buffer);

//使用cmd的proto结构体进行解析
$CmdMessage = new CmdData();
$CmdMessage->mergeFromString($cmd_buffer);
if($CmdMessage->getCmdIndex() == '1100')
{
    $LoginMessage = new LoginData();
    $LoginMessage->mergeFromString($data_buffer);
}

拼接Message结构体

$buffer = make(IJointBuffer::class)->Pack($CmdMessage, $DataMessage);