예제 #1
0
    async def reply_to(self, req, data=None):
        """
        Send a reply to the request req, with optional data in the reply.

        :param Request req: the original request
        :param bytes data: optional data to put in the reply
        """
        reply = Reply()
        reply.id = req.id
        if data:
            reply.data = data
        msg = Message()
        msg.type = Message.Reply
        msg.content = reply.SerializeToString()
        await self.send_message(msg)
예제 #2
0
    def reply_to(self, req, data=None):
        """
        Send a reply to the request req, with optional data in the reply.

        :param Request req: the original request
        :param bytes data: optional data to put in the reply
        """
        reply = Reply()
        reply.id = req.id
        if data:
            reply.data = data
        msg = Message()
        msg.type = Message.Reply
        msg.content = reply.SerializeToString()
        self.send_message(msg)
예제 #3
0
    async def reply_error_to(self, req, error_type, what=None):
        """
        Send an error reply to the request ``req``.

        :param Request req: The original request.
        :param Reply.Error error_type: An error code.
        :param bytes what: an error message.
        """
        error = Reply.Error()
        error.type = error_type
        if what is not None:
            error.what = what

        reply = Reply(id=req.id, error=error)

        msg = Message()
        msg.type = Message.Reply
        msg.content = reply.SerializeToString()
        await self.send_message(msg)
예제 #4
0
    def reply_error_to(self, req, error_type, what=None):
        """
        Send an error reply to the request ``req``.

        :param Request req: The original request.
        :param Reply.Error error_type: An error code.
        :param bytes what: an error message.
        """
        error = Reply.Error()
        error.type = error_type
        if what is not None:
            error.what = what

        reply = Reply(id=req.id, error=error)

        msg = Message()
        msg.type = Message.Reply
        msg.content = reply.SerializeToString()
        self.send_message(msg)