PHP 和 C++ 之间的 Msgpack

Msgpack between PHP and C++

我想将我的 class 从 C++ 客户端打包到 PHP 服务器并返回。但是当我尝试打包 PHP class 并将其解压缩为 C++ Class 时,我遇到了一个错误。

这是我在 PHP

中的代码
  class maplemessage
{
     var $nCode;            
     var $nType;            
     var $Text;            
     var $nRetrytime;       

     function setValue()
     {

     $this->nCode = 22;
     $this->nType = 12;
     $this->Text = "testmessage";
     $this->nRetrytime = 81;
     }
}
$msg1  = new maplemessage;
$msg1->setValue();

$binpacked =  msgpack_pack($msg1);

在我将打包的二进制数据发送到 C++ 客户端并尝试解压缩到 class

    class maplemessage {
public:

    int nCode;          
    int nType;          
    std::string Text;       
    int nRetrytime;     
public:
    MSGPACK_DEFINE(nCode, nType, Text, nRetrytime);
};

...

    msgpack::unpacked unp;
    msgpack::unpack(unp, tmpbyte.data(), tmpbyte.size());
    msgpack::object obj = unp.get();
    std::cout << obj << std::endl;
    msg1 = obj.as<maplemessage>();

然后我收到一个名为 "msgpack::v1::type_error"

的错误

有谁知道在 C++ 和 PHP 之间打包和解包 class 的正确方法是什么?

问题已解决:无论如何都不支持这样做。