Fixing msgpack custom
This commit is contained in:
parent
a5bd34e385
commit
d3f562cfa2
|
@ -897,9 +897,9 @@ else
|
|||
{
|
||||
function config_msgpack_pack($data)
|
||||
{
|
||||
include_once(__DIR__ . '/../utils/msgpack_custom.inc.php');
|
||||
include_once(__DIR__ . '/msgpack_custom.inc.php');
|
||||
|
||||
$packer = new MessagePackCustom();
|
||||
$packer = new \MessagePackCustom();
|
||||
return $packer->pack($data);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
class MessagePackCustom extends MessagePack\Packer
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(MessagePack\PackOptions::FORCE_STR);
|
||||
}
|
||||
|
||||
public function packStr($str)
|
||||
{
|
||||
$length = \strlen($str);
|
||||
|
||||
if ($length < 32) {
|
||||
return \chr(0xa0 | $length).$str;
|
||||
}
|
||||
if ($length <= 0xffff) {
|
||||
return "\xda".\chr($length >> 8).\chr($length).$str;
|
||||
}
|
||||
|
||||
return \pack('CN', 0xdb, $length).$str;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue