feat: print addr in log

This commit is contained in:
2021-05-17 23:38:32 +08:00
parent ea9f8788ad
commit 37d3553ab7
2 changed files with 10 additions and 11 deletions

View File

@@ -130,7 +130,7 @@ fn handle_text_message(handle_context: &mut HandleContext, tx: &Tx, addr: Socket
warning!("Not in room: {:?} - {:?}", room_id, client_id);
}
} else {
client_not_in_room(&tx);
client_not_in_room(&tx, addr);
}
},
RoomMessageType::Destroy => {
@@ -146,7 +146,7 @@ fn handle_text_message(handle_context: &mut HandleContext, tx: &Tx, addr: Socket
}
}
} else {
client_not_in_room(&tx);
client_not_in_room(&tx, addr);
}
},
RoomMessageType::ListPeers => {
@@ -172,7 +172,7 @@ fn handle_text_message(handle_context: &mut HandleContext, tx: &Tx, addr: Socket
m.send(&tx);
}
} else {
client_not_in_room(&tx);
client_not_in_room(&tx, addr);
}
},
RoomMessageType::Broadcast => {
@@ -204,7 +204,7 @@ fn handle_text_message(handle_context: &mut HandleContext, tx: &Tx, addr: Socket
}
}
} else {
client_not_in_room(&tx);
client_not_in_room(&tx, addr);
}
},
RoomMessageType::Peer => {
@@ -236,7 +236,7 @@ fn handle_text_message(handle_context: &mut HandleContext, tx: &Tx, addr: Socket
}
}
} else {
client_not_in_room(&tx);
client_not_in_room(&tx, addr);
}
},
}
@@ -290,15 +290,15 @@ async fn inner_handle_connection(
pin_mut!(broadcast_incoming, receive_from_others);
future::select(broadcast_incoming, receive_from_others).await;
information!("{} disconnected", &addr);
information!("Client disconnected: {}", &addr);
client_exit(&handle_context.room_map, &handle_context.room_id, &handle_context.client_id);
handle_context.peer_map.lock().unwrap().remove(&addr);
Ok(())
}
fn client_not_in_room(tx: &Tx) {
information!("Client is not in room");
fn client_not_in_room(tx: &Tx, addr: SocketAddr) {
information!("Client is not in room: {}", addr);
RoomMessageDown::create_error_reply("Client is not in room").send(tx);
}