'Received Msg with fields - this is a data response to a request.
If this is the last data block, issue a "done" callback.'

def _handle_event_fields(self, msg):

    seqnr = msg['fields']['seqnr']
    callback = self.sessions[seqnr]['callback']
    for node in msg['fields']['nodes']:
        for ts in node['timestamps']:
            fields = []
            for d in ts['datas']:
                field_block = {}
                field_block['name'] = d['name']
                field_block['typename'] = d._get_typename()
                field_block['value'] = d['value']
                if (not (d['unit'] == '')):
                    field_block['unit'] = d['unit']
                if (not (d['dataType'] == '')):
                    field_block['dataType'] = d['dataType']
                flags = d._get_flags()
                if (not (len(flags) == 0)):
                    field_block['flags'] = flags
                fields.append(field_block)
            callback(from_jid=msg['from'], result='fields', nodeId=node['nodeId'], timestamp=ts['value'], fields=fields)
    if (msg['fields']['done'] == 'true'):
        callback(from_jid=msg['from'], result='done')
        del self.sessions[seqnr]
