def handle_yo_message(self, message, address): # insert the new peer into our peerlist try: peer = find_peer_by_address(address) except PeerNotFoundException: new_peer = Peer(address) new_peer.tcp_port = message.port new_peer.alias = message.username peerlist.append(new_peer) else: peer.last_seen = datetime.now()
def handle_hi_message(self, message, address): # insert the new peer into our peerlist try: peer = find_peer_by_address(address) except PeerNotFoundException: new_peer = Peer(address) new_peer.tcp_port = message.port new_peer.alias = message.username peerlist.append(new_peer) else: peer.last_seen = datetime.now() # prepare a yo, but only if the hi did not come from myself if address not in settings.OWN_IP_ADDRESSES: yo = YoMessage(peerlist.self_peer.tcp_port, peerlist.self_peer.alias) self.send_message_to_multicast_group(yo)