Change logging

Signed-off-by: trivernis <trivernis@protonmail.com>
main
trivernis 4 years ago
parent d5a8b4e693
commit 5db478c64f
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -50,19 +50,19 @@ fn main() {
/// Sends Keep-Alive data to the server /// Sends Keep-Alive data to the server
fn keep_alive(pool: Arc<ScheduledThreadPool>, i: usize, address: String, port: u32, https: bool) { fn keep_alive(pool: Arc<ScheduledThreadPool>, i: usize, address: String, port: u32, https: bool) {
if let Some(mut stream) = create_connection(&*address, port, https) { if let Some(mut stream) = create_connection(&*address, port, https) {
println!("Connection {} established.", i); print!("Connection {} established. \r", i);
let pool_clone = Arc::clone(&pool); let pool_clone = Arc::clone(&pool);
pool.execute_at_fixed_rate( pool.execute_at_fixed_rate(
Duration::from_secs(fakeit::misc::random(5, 10)), Duration::from_secs(fakeit::misc::random(5, 10)),
Duration::from_secs(fakeit::misc::random(5, 10)), Duration::from_secs(fakeit::misc::random(5, 10)),
move || { move || {
println!(r#"Sending "Keep-Alive-Header" for connection {}..."#, i); print!("Sending Keep-Alive-Header for connection {}...\r", i);
if let Err(_) = stream.write_all(&[fakeit::misc::random(0u8, 255u8)]) { if let Err(e) = stream.write_all(&[fakeit::misc::random(0u8, 255u8)]) {
let address = address.clone(); let address = address.clone();
let pool_clone2 = Arc::clone(&pool_clone); let pool_clone2 = Arc::clone(&pool_clone);
println!("Connection {} lost. Reestablishing...", i); println!("Connection {} lost: {}. Reestablishing...", i, e);
pool_clone.execute(move || { pool_clone.execute(move || {
keep_alive(pool_clone2, i, address, port, https); keep_alive(pool_clone2, i, address, port, https);

Loading…
Cancel
Save