forked from n6cta/mwtchahrd
Send a UDP message to the server that says you are connected.
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -406,6 +406,7 @@ fn handle_frame(frame: &AgwFrame, cli: &Cli, buffers: &mut BufferManager) {
|
|||||||
"summary": &summary,
|
"summary": &summary,
|
||||||
"text": &text,
|
"text": &text,
|
||||||
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
|
"type": "data"
|
||||||
});
|
});
|
||||||
let _ = socket.expect("REASON").send_to(packet.to_string().as_bytes(), uaddr);
|
let _ = socket.expect("REASON").send_to(packet.to_string().as_bytes(), uaddr);
|
||||||
}
|
}
|
||||||
@@ -437,8 +438,13 @@ fn main() -> Result<()> {
|
|||||||
let socket = UdpSocket::bind("0.0.0.0:0")?;
|
let socket = UdpSocket::bind("0.0.0.0:0")?;
|
||||||
println!("UDP client started at {}:{}", cli.uip, cli.uport);
|
println!("UDP client started at {}:{}", cli.uip, cli.uport);
|
||||||
// Send a message to the server
|
// Send a message to the server
|
||||||
let message = "UDP client connected";
|
let packet = json!({
|
||||||
socket.send_to(message.as_bytes(), uaddr)?;
|
"text": "UDP client connected",
|
||||||
|
"timestamp": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(),
|
||||||
|
"type": "status"
|
||||||
|
});
|
||||||
|
//let message = "UDP client connected";
|
||||||
|
socket.send_to(packet.to_string().as_bytes(), uaddr)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
Reference in New Issue
Block a user