update connection_for_receiving

This commit is contained in:
Horhik 2021-04-19 18:03:31 +03:00
parent db89ca7bc2
commit 93874ee3ed
2 changed files with 10 additions and 11 deletions

View file

@ -1,4 +1,5 @@
use crate::chat::types::PackedMessage; use crate::chat::types::PackedMessage;
use std::sync::{Arc, Mutex};
use crate::db; use crate::db;
use async_std::{ use async_std::{
io, io,
@ -94,20 +95,18 @@ async fn connection_for_receiving(
// log::debug!("they are different"); // log::debug!("they are different");
match res { match res {
PackedMessage::FromCore(json) => { PackedMessage::FromCore(json) => {
let j = json.clone(); async_std::task::block_on(sender
sender .send(Message::Text(json))).expect("Couldn't send message")
.send(Message::Text(j))
.await
.expect("Couldn't send message");
} }
PackedMessage::FromFreenet(response) => { PackedMessage::FromFreenet(response) => {
let r = response.clone(); let r = response.clone();
log::debug!("Got:\n {}", &response); log::debug!("Got:\n {}", &response);
sender async_std::task::block_on(sender
// TODO freenet_response_handler // TODO freenet_response_handler
.send(Message::Text(r.to_string())) .send(Message::Text(r.to_string())));
.await // .await
.expect("Couldn't send messge"); // .expect("Couldn't send messge");
} }
_ => {} _ => {}
} }

View file

@ -11,7 +11,7 @@ pub async fn request_repeater(ss: SP) -> io::Result<()> {
//TODO create a field with tracked users //TODO create a field with tracked users
log::debug!("Request Repeater Started!"); log::debug!("Request Repeater Started!");
loop { loop {
let time = std::time::Duration::from_millis(600); let time = std::time::Duration::from_millis(1300);
std::thread::sleep(time); std::thread::sleep(time);
log::debug!("enough sleep"); log::debug!("enough sleep");
match ss.send(PackedMessage::ToFreenet( match ss.send(PackedMessage::ToFreenet(