37 lines
752 B
PHP
37 lines
752 B
PHP
<?php
|
|
namespace taskman;
|
|
use Exception;
|
|
|
|
if(function_exists('msgpack_pack'))
|
|
{
|
|
function config_msgpack_pack(array $data) : string
|
|
{
|
|
$prev = ini_set('msgpack.use_str8_serialization', '0');
|
|
$res = msgpack_pack($data);
|
|
if($prev != '0')
|
|
ini_set('msgpack.use_str8_serialization', $prev);
|
|
return $res;
|
|
}
|
|
|
|
function config_msgpack_unpack(string $data) : array
|
|
{
|
|
return msgpack_unpack($data);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
function config_msgpack_pack(array $data) : string
|
|
{
|
|
include_once(__DIR__ . '/msgpack/msgpack_custom.inc.php');
|
|
|
|
$packer = new \MessagePackCustom();
|
|
return $packer->pack($data);
|
|
}
|
|
|
|
function config_msgpack_unpack(string $data) : array
|
|
{
|
|
return \MessagePack\MessagePack::unpack($data);
|
|
}
|
|
}
|
|
|