Beispiel #1
0
    def on_request(self, ch, method, props, body):
        pkt = NetworkPacket.fromJson(body)
        type = pkt.data['catalog_name']
        n = NetworkPacket()

        if type in self.CATALOGS.keys():
            func = pkt.data['func']
            message = pkt.data['message']
            if func in self.FUNCS:
                if func == 'get_catalog':
                    offset = message['offset']
                    limit = message['limit']

                    n.data['status'] = 'OK'
                    n.data['message'] = toJson(self.CATALOGS[type], offset,
                                               limit)
            else:
                ApiWorker.send_error(ch, method, props, body,
                                     'Invalid func field')
                self.db.close()
        else:
            ApiWorker.send_error(ch, method, props, body,
                                 'Invalid catalog name')
            self.db.close()
            return
        ApiWorker.send_reply(ch, method, props, n.toJson())
        self.db.close()
        return
Beispiel #2
0
    def on_request(self, ch, method, props, body):
     pkt = NetworkPacket.fromJson(body)
     type = pkt.data['catalog_name']
     n = NetworkPacket()

     if type in self.CATALOGS.keys():
        func = pkt.data['func']
        message = pkt.data['message']
        if func in self.FUNCS:
            if func == 'get_catalog':
                offset = message['offset']
                limit = message['limit']
 
                n.data['status'] = 'OK'
                n.data['message'] = toJson(self.CATALOGS[type], offset, limit)
        else:
            ApiWorker.send_error(ch, method, props, body, 'Invalid func field')
            self.db.close()
     else:
        ApiWorker.send_error(ch, method, props, body, 'Invalid catalog name')
        self.db.close()
        return
     ApiWorker.send_reply(ch, method, props, n.toJson())
     self.db.close()
     return
Beispiel #3
0
 def on_request(self, ch, method, props, body):
     ApiWorker.send_reply(ch, method, props, "pong")
Beispiel #4
0
 def on_request(self, ch, method, props, body):
     ApiWorker.send_reply(ch, method, props, "pong")