def handle_connect_peer(self, request):
     logger.info("peer address msg: {}".format(request.peer_address))
     peer_address = message_to_peer_address(request.peer_address)
     logger.info(
         "Handle connect peer with peer address: {}".format(peer_address))
     self.squeak_controller.connect_peer(peer_address)
     return squeak_admin_pb2.ConnectPeerReply()
 def handle_get_squeak_peer_by_address(self, request):
     peer_address = message_to_peer_address(request.peer_address)
     logger.info(
         "Handle get squeak peer with address: {}".format(peer_address))
     squeak_peer = self.squeak_controller.get_peer_by_address(peer_address)
     squeak_peer_msg = optional_squeak_peer_to_message(squeak_peer)
     return squeak_admin_pb2.GetPeerByAddressReply(
         squeak_peer=squeak_peer_msg, )
 def handle_get_connected_peer(self, request):
     peer_address = message_to_peer_address(request.peer_address)
     logger.info("Handle get connected peer for address: {}".format(
         peer_address, ))
     connected_peer = self.squeak_controller.get_connected_peer(
         peer_address)
     logger.info("Connected peer: {}".format(connected_peer, ))
     connected_peers_display_msg = optional_connected_peer_to_message(
         connected_peer)
     return squeak_admin_pb2.GetConnectedPeerReply(
         connected_peer=connected_peers_display_msg)
 def handle_create_peer(self, request):
     peer_name = request.peer_name
     peer_address = message_to_peer_address(request.peer_address)
     logger.info("Handle create peer with name: {}, address: {}".format(
         peer_name,
         peer_address,
     ))
     peer_id = self.squeak_controller.create_peer(
         peer_name,
         peer_address,
     )
     return squeak_admin_pb2.CreatePeerReply(peer_id=peer_id, )
 def handle_subscribe_connected_peer(self, request, stopped):
     peer_address = message_to_peer_address(request.peer_address)
     logger.info(
         "Handle subscribe connected peer with peer address: {}".format(
             peer_address))
     connected_peer_stream = self.squeak_controller.subscribe_connected_peer(
         peer_address,
         stopped,
     )
     for connected_peer in connected_peer_stream:
         connected_peer_display_msg = optional_connected_peer_to_message(
             connected_peer)
         yield squeak_admin_pb2.GetConnectedPeerReply(
             connected_peer=connected_peer_display_msg, )
예제 #6
0
def test_msg_to_peer_address(peer_address, peer_address_message):
    address = message_to_peer_address(peer_address_message)

    assert address == peer_address