def read_response(self): packet = read_packet(self._connfd) if packet.header.ptype != CCNET_MSG_RESPONSE: raise RuntimeError('Invalid Response') code, code_msg, content = parse_response(packet.body) return Response(code, code_msg, content)
def handle_packet(self, pkt): ptype = pkt.header.ptype if ptype == CCNET_MSG_REQUEST: self.handle_request(pkt.header.id, pkt.body) elif ptype == CCNET_MSG_UPDATE: code, code_msg, content = parse_update(pkt.body) self.handle_update(pkt.header.id, code, code_msg, content) elif ptype == CCNET_MSG_RESPONSE: code, code_msg, content = parse_response(pkt.body) self.handle_response(pkt.header.id, code, code_msg, content) else: logging.warning("unknown packet type %d", ptype)