Compare commits
2 Commits
b1f31a0de8
...
1e67b80d10
| Author | SHA1 | Date | |
|---|---|---|---|
|
1e67b80d10
|
|||
|
6024798053
|
Generated
+1
@@ -397,6 +397,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "fedichat"
|
name = "fedichat"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
source = "git+https://git.firechicken.net/fedichat/fedichat-lib#49cbd905ceecb7bf7be463f81836742e3a7ddc24"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde",
|
"serde",
|
||||||
"serde_bytes",
|
"serde_bytes",
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@ edition = "2024"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quinn = "0.11.9"
|
quinn = "0.11.9"
|
||||||
#fedichat = {git = "https://git.firechicken.net/fedichat/fedichat-lib"}
|
fedichat = {git = "https://git.firechicken.net/fedichat/fedichat-lib"}
|
||||||
fedichat = {path = "../fedichat-lib"}
|
#fedichat = {path = "../fedichat-lib"}
|
||||||
tracing = "0.1.44"
|
tracing = "0.1.44"
|
||||||
tracing-subscriber = "0.3.23"
|
tracing-subscriber = "0.3.23"
|
||||||
clap = { version = "4.6.1", features = ["derive"] }
|
clap = { version = "4.6.1", features = ["derive"] }
|
||||||
|
|||||||
+15
-3
@@ -90,6 +90,8 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
debug!("Sending commands");
|
debug!("Sending commands");
|
||||||
|
|
||||||
|
|
||||||
|
let mut response: fedichat::client::ServerMessage = ServerMessage::Ok;
|
||||||
|
|
||||||
for message in messages {
|
for message in messages {
|
||||||
let mut buf = Vec::new();
|
let mut buf = Vec::new();
|
||||||
|
|
||||||
@@ -104,7 +106,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// Max response should never be this big but we can spare the memory
|
// Max response should never be this big but we can spare the memory
|
||||||
let received = recv.read_to_end(1000 * 1000).await?;
|
let received = recv.read_to_end(1000 * 1000).await?;
|
||||||
|
|
||||||
let response: fedichat::client::ServerMessage = rmp_serde::from_slice(&received)?;
|
response = rmp_serde::from_slice(&received)?;
|
||||||
// If we received a message that gave us a new token then update the local copy
|
// If we received a message that gave us a new token then update the local copy
|
||||||
match response {
|
match response {
|
||||||
ServerMessage::Token(ref token) => {
|
ServerMessage::Token(ref token) => {
|
||||||
@@ -114,12 +116,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let mut file = File::create(file_to_write.clone().expect("File path not specified"))?;
|
let mut file = File::create(file_to_write.clone().expect("File path not specified"))?;
|
||||||
file.write_all(bytes)?;
|
file.write_all(bytes)?;
|
||||||
},
|
},
|
||||||
|
ServerMessage::Error(_) => {
|
||||||
|
break;
|
||||||
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:?}",response);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
println!("{}",format_response(response));
|
||||||
|
|
||||||
// On listen specifically we will stay connected
|
// On listen specifically we will stay connected
|
||||||
|
|
||||||
@@ -128,6 +133,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fn format_response(m: ServerMessage) -> String {
|
||||||
|
match m {
|
||||||
|
ServerMessage::Media(_) => "File received".to_string(),
|
||||||
|
m => format!("{:?}",m)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user