use std::net::SocketAddr; use fleck::fleck_core; fn main() { pretty_env_logger::init_timed(); let fleck = fleck::API::new(); // generate ephemeral keypair fleck.with_service(|ns: &fleck_core::NodeService| { ns.build_ephemeral_self_node(); }); // create UDP socket for communication with a local multicast group let sockref = fleck.with_service(|io: &fleck_core::io::IOService| { fleck_core::io::UdpSocketBuilder::default() .bind_to(SocketAddr::new( std::net::Ipv4Addr::UNSPECIFIED.into(), 3535, )) .join_multicast("239.0.239.0".parse().unwrap(), "0.0.0.0".parse().unwrap()) .build(io) }); // enable local discovery fleck.with_service(|ld: &fleck_core::discovery::LocalDiscovery| { for peer in sockref.multicast_peers() { ld.add_multicast_peer(peer); } }); // run and perform all automatic services, but don't do anything interesting... fleck.run(); }