taskman_config/msgpack/msgpack_custom.inc.php

24 lines
468 B
PHP
Raw Normal View History

2022-05-16 17:52:12 +03:00
<?php
2022-05-16 17:55:38 +03:00
class MessagePackCustom extends \MessagePack\Packer
2022-05-16 17:52:12 +03:00
{
public function __construct()
{
2022-05-16 17:55:38 +03:00
parent::__construct(\MessagePack\PackOptions::FORCE_STR);
2022-05-16 17:52:12 +03:00
}
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;
}
}