fix sending adress in handlers.rs
This commit is contained in:
parent
a862520d4e
commit
4c2dcb74f6
|
@ -125,7 +125,7 @@ pub fn send_message(
|
||||||
}
|
}
|
||||||
|
|
||||||
let freenet_message = crate::api::response::FreenetMessage {
|
let freenet_message = crate::api::response::FreenetMessage {
|
||||||
id: id.clone().0,
|
id: parsed.id.0, // My identifier
|
||||||
message: message.clone(),
|
message: message.clone(),
|
||||||
date: date.clone(),
|
date: date.clone(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[serde(tag = "type")]
|
||||||
pub struct Message {
|
pub struct Message {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub date: Time,
|
pub date: Time,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::api::types::Message as FrontMessage;
|
|
||||||
use super::serv_handler::to_server_sender;
|
use super::serv_handler::to_server_sender;
|
||||||
|
use crate::api::types::Message as FrontMessage;
|
||||||
use crate::chat::types::{PackedMessage, RP, SP};
|
use crate::chat::types::{PackedMessage, RP, SP};
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use fcpv2::types::traits::FcpParser;
|
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);
|
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 data_length: usize = usize::from_str_radix(&captured[4], 10).unwrap();
|
||||||
let message = &captured[7][0..data_length].to_string();
|
let message = &captured[7][0..data_length].to_string();
|
||||||
let parsed_message =
|
let parsed_message = serde_json::from_str::<
|
||||||
serde_json::from_str::<crate::api::response::FreenetMessage>(&message[..]);
|
crate::api::response::FreenetMessage,
|
||||||
|
>(&message[..]);
|
||||||
match parsed_message {
|
match parsed_message {
|
||||||
Ok(json) => {
|
Ok(json) => {
|
||||||
let front_message = FrontMessage {
|
let front_message = FrontMessage {
|
||||||
|
@ -112,20 +113,18 @@ async fn server_responce_getter(mut receiver: OwnedReadHalf, client_sender: SP)
|
||||||
id: json.id,
|
id: json.id,
|
||||||
message: json.message,
|
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(_) => {
|
Err(_) => {
|
||||||
log::error!("Failed to parse gotted message");
|
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" => {
|
"AllData" => {
|
||||||
log::debug!("Receive a new message!!! {:?}", &received);
|
log::debug!("Receive a new message!!! {:?}", &received);
|
||||||
|
|
Loading…
Reference in a new issue