def _process_new_message(self, new_message: message.Message, peer: peer.Peer): if isinstance(new_message, message.Choke): peer.handle_choke() elif isinstance(new_message, message.UnChoke): peer.handle_unchoke() elif isinstance(new_message, message.Interested): peer.handle_interested() elif isinstance(new_message, message.NotInterested): peer.handle_not_interested() elif isinstance(new_message, message.Have): peer.handle_have(new_message) elif isinstance(new_message, message.BitField): peer.handle_bitfield(new_message) elif isinstance(new_message, message.Request): peer.handle_request(new_message) elif isinstance(new_message, message.Piece): peer.handle_piece(new_message)
def _process_new_message(self, new_message, peer): """ :type peer: peer.Peer :type new_message: message.Message """ if isinstance(new_message, message.Handshake) or isinstance(new_message, message.KeepAlive): logging.error("Handshake or KeepALive should have already be handled") elif isinstance(new_message, message.Choke): peer.handle_choke() elif isinstance(new_message, message.UnChoke): peer.handle_unchoke() elif isinstance(new_message, message.Interested): peer.handle_interested() elif isinstance(new_message, message.NotInterested): peer.handle_not_interested() elif isinstance(new_message, message.Have): peer.handle_have(new_message) elif isinstance(new_message, message.BitField): peer.handle_bitfield(new_message) elif isinstance(new_message, message.Request): peer.handle_request(new_message) elif isinstance(new_message, message.Piece): peer.handle_piece(new_message) elif isinstance(new_message, message.Cancel): peer.handle_cancel() elif isinstance(new_message, message.Port): peer.handle_port_request() else: logging.error("Unknown message")