def handler(raw_msg): if 'result' in raw_msg: op = ResponseMessage.create(raw_msg) else: op = invocation_message(raw_msg) if op or not self.ignore_invalid_messages: callback(op) else: if callable(self.on_bad_message): self.on_bad_message(raw_msg) else: print "Bad Message", repr(raw_msg)
def write_response(self, command, callback): "Sends a given command back as a response." if not callable(getattr(command, "to_network", None)): command = ResponseMessage.create(command) self.stream.write(command, callback=callback) print "mediator <-", command
def write_response(self, command, callback): "Sends a given command back as a response." if not callable(getattr(command, 'to_network', None)): command = ResponseMessage.create(command) self.stream.write(command, callback=callback) print "mediator <-", command