graph/
graph.rs

1use std::time::Duration;
2
3use libmapper_rs::{constants::{mpr_prop, mpr_type}, graph::Graph, object::MapperObject};
4
5/// Prints out a list of all device names found on the network
6
7fn main() {
8  let graph = Graph::create();
9  let mut count = 0;
10
11  // Have to subscribe to all devices first in order to discover devices we don't own!
12  graph.subscribe(None, &[mpr_type::MPR_DEV]);
13
14  loop {
15
16    graph.poll_and_block(Duration::from_millis(10));
17    let list = graph.get_devices();
18
19    if list.len() != 0 {
20      for dev in list {
21        println!("Found device: {:?}", dev.get_property_str(mpr_prop::MPR_PROP_NAME).unwrap());
22      }
23      break;
24    }
25    
26    println!("Loop {}", count);
27    count += 1;
28  }
29  
30}