fix sending adress in handlers.rs

This commit is contained in:
horhik 2021-04-28 19:37:30 +03:00
parent a862520d4e
commit 4c2dcb74f6
3 changed files with 13 additions and 13 deletions

View file

@ -125,7 +125,7 @@ pub fn send_message(
}
let freenet_message = crate::api::response::FreenetMessage {
id: id.clone().0,
id: parsed.id.0, // My identifier
message: message.clone(),
date: date.clone(),
};

View file

@ -3,6 +3,7 @@ use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(rename_all = "camelCase")]
#[serde(tag = "type")]
pub struct Message {
pub message: String,
pub date: Time,

View file

@ -1,5 +1,5 @@
use crate::api::types::Message as FrontMessage;
use super::serv_handler::to_server_sender;
use crate::api::types::Message as FrontMessage;
use crate::chat::types::{PackedMessage, RP, SP};
use async_std::task;
use fcpv2::types::traits::FcpParser;
@ -102,8 +102,9 @@ async fn server_responce_getter(mut receiver: OwnedReadHalf, client_sender: SP)
log::debug!("\n\n\n\n\n AAAAAAAAA {:?} \n\n\n\n", captured);
let data_length: usize = usize::from_str_radix(&captured[4], 10).unwrap();
let message = &captured[7][0..data_length].to_string();
let parsed_message =
serde_json::from_str::<crate::api::response::FreenetMessage>(&message[..]);
let parsed_message = serde_json::from_str::<
crate::api::response::FreenetMessage,
>(&message[..]);
match parsed_message {
Ok(json) => {
let front_message = FrontMessage {
@ -112,20 +113,18 @@ async fn server_responce_getter(mut receiver: OwnedReadHalf, client_sender: SP)
id: json.id,
message: json.message,
};
client_sender.send(PackedMessage::ToClient(serde_json::to_string(&front_message).unwrap())).unwrap();
client_sender
.send(PackedMessage::FromCore(
serde_json::to_string(&front_message).unwrap(),
))
.unwrap();
log::debug!("Send gotted message to frontend...");
}
Err(_) => {
log::error!("Failed to parse gotted message");
}
}
log::debug!("Parse new message!!!! {:?}", &message);
client_sender
.send(PackedMessage::ToClient(
message.to_string(),
))
.unwrap();
let mut lines = &received.clone().lines();
}
"AllData" => {
log::debug!("Receive a new message!!! {:?}", &received);