taskman_config/msgpack_custom.inc.php

24 lines
468 B
PHP

<?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;
}
}