示例#1
0
 def __recv_msg(self):
     header = MessageBuf(self.__recv_bytes(2))
     data_len = header.get_uint16(be=True)
     msg = MessageBuf(self.__recv_bytes(data_len))
     if self.verbose:
         self.info('< ' + str(msg))
     return msg
示例#2
0
    def __init__(self, resname, resver, rawinfo):
        self.resname = resname
        self.resver = resver

        buf = MessageBuf(rawinfo)

        canon_sig = 'Haven Resource 1'
        sig = buf.get_bytes(len(canon_sig))
        if sig != canon_sig:
            raise ResException('Wrong signature')

        ver = buf.get_uint16()
        if ver != self.resver:
            raise ResException('Wrong version')

        self.layers = []
        while not buf.eom():
            layer_type = buf.get_string()
            layer_len = buf.get_int32()
            layer_data = buf.get_bytes(layer_len)
            self.layers.append(ResLayer(layer_type, layer_data))