示例#1
0
文件: chunks.py 项目: DxCx/twimp
def _encode_basic_header(h_type, cs_id, time=None):
    if cs_id > 0x013f:  # 256 + 63
        base = _s_ext_csid.pack((h_type << 6) | 1, cs_id - 64)
    elif cs_id > 0x3f:  # 63
        base = _s_double_uchar.pack(h_type << 6, cs_id - 64)
    else:
        base = _s_uchar.pack((h_type << 6) | cs_id)

    if time >= 0x00ffffff:  # implicit None < int
        return base + _s_ulong_b.pack(time)

    return base
示例#2
0
文件: chunks.py 项目: davibe/twimp
def _encode_basic_header(h_type, cs_id, time=None):
    if cs_id > 0x013f:          # 256 + 63
        base = _s_ext_csid.pack((h_type << 6) | 1, cs_id - 64)
    elif cs_id > 0x3f:          # 63
        base = _s_double_uchar.pack(h_type << 6, cs_id - 64)
    else:
        base = _s_uchar.pack((h_type << 6) | cs_id)

    if time >= 0x00ffffff:       # implicit None < int
        return base + _s_ulong_b.pack(time)

    return base
示例#3
0
 def __init__(self, protocol, epoch_base, is_client=False):
     self.epoch = epoch_base
     self.version_packet = _s_uchar.pack(self.protocol_version)
     self.protocol = protocol
     self.is_client = is_client
示例#4
0
 def __init__(self, protocol, epoch_base, is_client=False):
     self.epoch = epoch_base
     self.version_packet = _s_uchar.pack(self.protocol_version)
     self.protocol = protocol
     self.is_client = is_client