def _send_response(self, response): response = Response.build(response) response.id = self.id response.target = self.origin response.origin = Config.get('device_id') if self.backend and self.origin: self.backend.send_response(response=response, request=self) else: redis = get_plugin('redis') if redis: queue_name = get_redis_queue_name_by_message(self) redis.send_message(queue_name, response) redis.expire(queue_name, 60)
def send_response(self, response, request, **kwargs): """ Send a response message on the backend Params: response -- The response, either a dict, a string/bytes UTF-8 JSON, or a platypush.message.response.Response object request -- Associated request, used to set the response parameters that will link them """ response = Response.build(response) assert isinstance(response, Response) assert isinstance(request, Request) response.id = request.id response.target = request.origin response.origin = self.device_id self.send_message(response, **kwargs)