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
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