def on_chunk()

in craft-server-image/server.py [0:0]


    def on_chunk(self, client, p, q, key=0):
        #log('on_chunk-select from block',p,q)
        packets = []
        p, q, key = map(int, (p, q, key))
        query = (
            'select rowid, x, y, z, w from block where '
            'p = :p and q = :q and rowid > :key;'
        )
        rows = self.execute(query, dict(p=p, q=q, key=key))
        max_rowid = 0
        blocks = 0
        
        sql_parameters = [
            {'name':'p', 'value':{'doubleValue': p}},
            {'name':'q', 'value':{'doubleValue': q}},
            {'name':'key', 'value':{'doubleValue': key}},
        ]
        result = execute_rds_statement(query, sql_parameters)
        log('rds_response on_chunk',result['records'])
        for _row in result['records']:
            rowid=_row[0]['longValue']
            x=_row[1]['longValue']
            y=_row[2]['longValue']
            z=_row[3]['longValue']
            w=_row[4]['longValue']
            log('on_chunk-result[records]',rowid,x,y,z,w)
            blocks += 1
            packets.append(packet(BLOCK, p, q, x, y, z, w))
            max_rowid = max(max_rowid, rowid)
        #for rowid, x, y, z, w in rows:
            #log('on_chunk-rows',x,y,z,w)
            #blocks += 1
            #packets.append(packet(BLOCK, p, q, x, y, z, w))
            #max_rowid = max(max_rowid, rowid)
        query = (
            'select x, y, z, w from light where '
            'p = :p and q = :q;'
        )
        rows = self.execute(query, dict(p=p, q=q))

        lights = 0
        for x, y, z, w in rows:
            lights += 1
            packets.append(packet(LIGHT, p, q, x, y, z, w))
        query = (
            'select x, y, z, face, text from sign where '
            'p = :p and q = :q;'
        )
        rows = self.execute(query, dict(p=p, q=q))
        signs = 0
        for x, y, z, face, text in rows:
            signs += 1
            packets.append(packet(SIGN, p, q, x, y, z, face, text))
        if blocks:
            packets.append(packet(KEY, p, q, max_rowid))
        if blocks or lights or signs:
            packets.append(packet(REDRAW, p, q))
        packets.append(packet(CHUNK, p, q))
        client.send_raw(''.join(packets))