docs(multiplexer): tidy up examples

This commit is contained in:
Santiago Carmuega 2021-12-11 19:35:05 -03:00
parent 87c423a22b
commit fec280728b
3 changed files with 30 additions and 10 deletions

View file

@ -1,5 +1,6 @@
use std::{os::unix::net::UnixStream, thread, time::Duration};
use std::{net::TcpStream, thread, time::Duration};
use log::info;
use pallas_multiplexer::{Channel, Multiplexer};
const PROTOCOLS: [u16; 2] = [0x0002u16, 0x0003u16];
@ -7,8 +8,8 @@ const PROTOCOLS: [u16; 2] = [0x0002u16, 0x0003u16];
fn main() {
env_logger::init();
//let bearer = TcpStream::connect("127.0.0.1:3001").unwrap();
let bearer = UnixStream::connect("/tmp/pallas").unwrap();
info!("connecting to tcp socket on 127.0.0.1:3001");
let bearer = TcpStream::connect("127.0.0.1:3001").unwrap();
let mut muxer = Multiplexer::setup(bearer, &PROTOCOLS).unwrap();
for protocol in PROTOCOLS {
@ -19,8 +20,9 @@ fn main() {
loop {
let payload = vec![1; 65545];
info!("sending dumb payload for protocol: {}", protocol);
tx.send(payload).unwrap();
thread::sleep(Duration::from_millis(50u64 + (protocol as u64 * 10u64)));
thread::sleep(Duration::from_millis(500u64 + (protocol as u64 * 10u64)));
}
});
}