I want to pack my class from C++ Client to PHP Server and back. but when I try to pack a PHP class and unpack it to C++ Class I got a error.
this is my code in 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);
and after I send the packed binary data to C++ Client and try to unpack to the 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>();
and then I got an error named "msgpack::v1::type_error"
anyone knows what is the right way to pack and unpack a class between C++ and PHP?
问题已解决:仍然不支持这样做。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.