This commit is contained in:
azw 2024-05-12 20:14:00 +08:00
parent e6a625ba4e
commit ca5411e9da
2 changed files with 7 additions and 5 deletions

View File

@ -30,10 +30,11 @@ impl UpStream {
pub fn init(&self, rt: &tokio::runtime::Runtime) {
{
//let down_pack_queue = self.down_pack_queue.clone();
//let up_pack_queue = self.up_pack_queue.clone();
let down_pack_queue = self.down_pack_queue.clone();
let up_pack_queue = self.up_pack_queue.clone();
let address = format!("{0}:{1}", self.remote_ip, self.remote_port);
rt.spawn(async move {
let mut result = TcpStream::connect("192.168.100.39:7616").await;
let mut result = TcpStream::connect(address).await;
match result {
Ok(v) => {
let a = Arc::new(Mutex::new(v));

View File

@ -9,8 +9,8 @@ use crate::app::UserApp;
pub struct UpStreamMgr {
curr_id: i16,
key_hash: Rc::<RefCell::<HashMap<String, Rc::<UpStream>>>>,
id_hash: Rc::<RefCell::<HashMap<i32, Rc::<UpStream>>>>,
key_hash: RefCell::<HashMap<String, Rc::<UpStream>>>,
id_hash: RefCell::<HashMap<i32, Rc::<UpStream>>>,
tokio_rt: Runtime,
}
unsafe impl Send for UpStreamMgr{}
@ -36,6 +36,7 @@ impl UpStreamMgr {
pub fn init(&self) {
let upstream = Rc::new(UpStream::new(1, "192.168.100.39".to_string(), 7616));
self.key_hash.borrow_mut().insert("".to_string(), upstream.clone());
self.id_hash.borrow_mut().insert(upstream.instance_id, upstream.clone());
upstream.init(&self.tokio_rt);