feat: print addr in log
This commit is contained in:
16
src/main.rs
16
src/main.rs
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
use tungstenite::Message;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::types::Tx;
|
||||
use crate::types::{Tx, TxSendMessage};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||
pub enum RoomMessageType {
|
||||
@@ -79,7 +78,7 @@ impl RoomMessageDown {
|
||||
|
||||
pub fn send(&self, tx: &Tx) {
|
||||
if let Ok(mm) = serde_json::to_string(self) {
|
||||
tx.unbounded_send(Message::Text(mm)).ok();
|
||||
tx.send_text(mm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user