def listen(self, message, options=None):
     if self.closing is True: return
     if isinstance(message, Request):
         if self.worker is True:
             self.flinger.unsubscribe(self,message.name)
         self.callbacks[message.request_id]=message
         logging.debug('handling %s',message.request_id)
         self.write_message(utils.dumps({"request_id":message.request_id,
                                         "name": message.name,
                                         "options":message.options}))
     else:
         logging.debug('listening %s',message)
         self.write_message(utils.dumps({"message":message, 
                                         "options":options}))
     return True
 def handled(self, request):
     if self.closing is True: return
     response = {
         "result": request.result,
         "error": request.error,
         "response_id": request.request_id
     }
     self.requests.remove(request)
     logging.debug(response)
     self.write_message(utils.dumps(response))
     logging.info("wrote %s",request.request_id)
Exemple #3
0
 def write_message(self, message):
     self._connection.write_message(utils.dumps(message))