def on_second_service_request(request):
     response = Response(request)
     response.payload = expected_second_service_response_payload
     try:
         client.send_response(response)
     except DxlException as ex:
         print("Failed to send response" + str(ex))
示例#2
0
 def on_second_service_request(request):
     response = Response(request)
     response.payload = bytes(second_service_response_payload)
     try:
         client.send_response(response)
     except DxlException, ex:
         print "Failed to send response" + str(ex)
示例#3
0
 def my_request_callback(request):
     try:
         time.sleep(0.05)
         resp = Response(request)
         resp.payload = request.payload
         client.send_response(resp)
     except Exception as ex:  # pylint: disable=broad-except
         print(ex)
示例#4
0
 def my_request_callback(rq):
     # print "request: " + str(rq.version)
     try:
         time.sleep(0.05)
         resp = Response(rq)
         resp.payload = rq.payload
         client.send_response(resp)
     except Exception, e:
         print e.message
示例#5
0
        def on_request(request):
            logging.info(request.destination_topic)
            logging.info(request.payload)

            response = Response(request)
            response.payload = bytes("Ok")
            try:
                client.send_response(response)
            except DxlException, ex:
                print "Failed to send response" + str(ex)
示例#6
0
            def on_request(request):
                print("## Request in service: " + request.destination_topic + ", " + str(request.message_id))
                print("## Request in service - payload: " + request.payload)

                service_request_message.append(request.message_id)
                service_request_message_receive_payload.append(request.payload)

                response = Response(request)
                response.payload = "Request response - Event payload: " + request.payload
                client.send_response(response)
        def on_request(request):
            logging.info(request.destination_topic)
            logging.info(request.payload)

            if on_client_request_callback:
                on_client_request_callback()
            response = Response(request)
            response.payload = "Ok"
            try:
                client.send_response(response)
            except DxlException as ex:
                print("Failed to send response" + str(ex))
    def test_request_and_response(self):
        reply_to_channel = "/mcafee/client/" + UuidGenerator.generate_id_as_string()
        service_guid = UuidGenerator.generate_id_as_string()
        source_client_guid = UuidGenerator.generate_id_as_string()
        source_broker_guid = UuidGenerator.generate_id_as_string()

        request = Request(destination_topic="")
        request.reply_to_channel = reply_to_channel
        request.service_id = service_guid
        request._source_client_id = source_client_guid
        request._source_broker_id = source_broker_guid
        request.broker_ids = ["{66000000-0000-0000-0000-000000000001}",
                              "{66000000-0000-0000-0000-000000000002}",
                              "{66000000-0000-0000-0000-000000000003}"]
        request.client_ids = ["{25000000-0000-0000-0000-000000000001}",
                              "{25000000-0000-0000-0000-000000000002}",
                              "{25000000-0000-0000-0000-000000000003}"]
        request.payload = "REQUEST".encode()

        PP.pprint(vars(request))
        message = request._to_bytes()
        PP.pprint(message)

        self.assertEqual(source_client_guid, request.source_client_id)

        result = Message._from_bytes(message)
        PP.pprint(vars(result))

        response = Response(request=request)
        response.payload = "RESPONSE".encode()

        PP.pprint(vars(response))
        message = response._to_bytes()
        PP.pprint(message)
        result = Message._from_bytes(message)
        PP.pprint(vars(result))

        self.assertEqual(Message.MESSAGE_TYPE_RESPONSE, result.message_type)
 def reg_info_request_2(request):
     response = Response(request)
     response.payload = "service2"
     service_client.send_response(response)