Exemple #1
0
    def handle_response(self, code, code_msg, content):
        if self.state == REQUEST_SENT: 
            if code[0] != '2':
                logging.warning('bad response: %s %s\n', code, code_msg)
                self.done(False)

            self.state = READY

        elif self.state == READY:
            if code[0] != '2' and code[0] != '3':
                logging.warning('bad response: %s %s\n', code, code_msg)
                return

            if code[0] == '3' and code[2] == '0':
                msg = message_from_string(content)
                if self.callback:
                    self.callback(msg)
Exemple #2
0
    def handle_response(self, code, code_msg, content):
        if self.state == REQUEST_SENT:
            if code[0] != "2":
                logging.warning("bad response: %s %s\n", code, code_msg)
                self.done(False)

            self.state = READY

        elif self.state == READY:
            if code[0] != "2" and code[0] != "3":
                logging.warning("bad response: %s %s\n", code, code_msg)
                return

            if code[0] == "3" and code[2] == "0":
                msg = message_from_string(content)
                if self.callback:
                    self.callback(msg)
Exemple #3
0
 def receive_message(self):
     resp = self.read_response()
     # the message from ccnet daemon has the trailing null byte included
     msg = message_from_string(resp.content[:-1])
     return msg
 def receive_message(self):
     resp = self.read_response()
     # the message from ccnet daemon has the trailing null byte included
     msg = message_from_string(resp.content[:-1])
     return msg