void query_response_handler(mapper_signal sig, mapper_db_signal props, mapper_timetag_t *timetag, void *v) { mapper_signal remote = (mapper_signal) props->user_data; mapper_db_signal remote_props = msig_properties(remote); printf("--> source got query response: %s %f\n", remote_props->name, (*(float*)v)); received++; }
/* TODO: Bundle messages together that happen in the same call to poll(). */ void text_write_value(mapper_signal msig, void *v, mapper_timetag_t *tt) { int i; char str[1024], *path = str; msig_full_name(msig, path, 1024); if (path[0]=='/') path ++; while (path[0] && path[0]!='/') path ++; lo_timetag now; lo_timetag_now(&now); mapper_db_signal mprop = msig_properties(msig); if (!tt || !tt->sec) fprintf(output_file, "%u %u %s %c ", now.sec, now.frac, path, mprop->type); else fprintf(output_file, "%u %u %s %c ", tt->sec, tt->frac, path, mprop->type); if (mprop->type == 'i') { for (i=0; i<mprop->length; i++) fprintf(output_file, " %d", ((int*)v)[i]); } else if (mprop->type == 'f') { for (i=0; i<mprop->length; i++) fprintf(output_file, " %g", ((float*)v)[i]); } fprintf(output_file, "\n"); fflush(output_file); if (now.sec > last_write.sec) { printf("."); fflush(stdout); last_write = now; } }