Exemplo n.º 1
0
    def datagram_received(self, data, addr):
        try:
            reply = Packet(packet=data, dict=self.client.dict)

            if reply and reply.id in self.pending_requests:
                req = self.pending_requests[reply.id]
                packet = req['packet']

                reply.dict = packet.dict
                reply.secret = packet.secret

                if packet.VerifyReply(reply, data):
                    req['future'].set_result(reply)
                    # Remove request for map
                    del self.pending_requests[reply.id]
                else:
                    self.logger.warn(
                        '[%s:%d] Ignore invalid reply for id %d. %s',
                        self.server, self.port, reply.id)
            else:
                self.logger.warn('[%s:%d] Ignore invalid reply: %d',
                                 self.server, self.port, data)

        except Exception as exc:
            self.logger.error('[%s:%d] Error on decode packet: %s',
                              self.server, self.port, exc)
Exemplo n.º 2
0
    def datagram_received(self, data, addr):
        try:
            reply = Packet(packet=data, dict=self.client.dict)
            self.logger.info(reply)

            if reply and reply.id in self.pending_requests:
                self.logger.info('Request found')
                req = self.pending_requests[reply.id]
                packet = req['packet']

                reply.dict = packet.dict
                reply.secret = packet.secret

                if packet.VerifyReply(reply, data):
                    req['future'].set_result(reply)
                    # Remove request for map
                    del self.pending_requests[reply.id]
                else:
                    self.logger.warn(
                        '[{}:{}] Ignore invalid reply for id {}'.format(
                            self.server, self.port, reply.id))
            else:
                self.logger.info('Request was not found')
                try:
                    self.logger.warn('[{}:{}] Ignore invalid reply: {}'.format(
                        self.server, self.port, data.decode('utf-8')))
                except:
                    self.logger.warn('[{}:{}] Ignore invalid reply: {}'.format(
                        self.server, self.port, data))

        except Exception as exc:
            self.logger.error('[{}:{}] Error on decode packet: {}'.format(
                self.server, self.port, exc))
Exemplo n.º 3
0
    def datagram_received(self, data, addr):
        try:
            reply = Packet(packet=data, dict=self.client.dict)

            if reply and reply.id in self.pending_requests:
                req = self.pending_requests[reply.id]
                packet = req['packet']

                reply.dict = packet.dict
                reply.secret = packet.secret

                if packet.VerifyReply(reply, data):
                    req['future'].set_result(reply)
                    # Remove request for map
                    del self.pending_requests[reply.id]
                else:
                    self.logger.warn('[%s:%d] Ignore invalid reply for id %d. %s', self.server, self.port, reply.id)
            else:
                self.logger.warn('[%s:%d] Ignore invalid reply: %d', self.server, self.port, data)

        except Exception as exc:
            self.logger.error('[%s:%d] Error on decode packet: %s', self.server, self.port, exc)