1
This commit is contained in:
parent
f6465da990
commit
0c6c7cc41d
@ -3,16 +3,24 @@ use std::cell::RefCell;
|
||||
use r9_macro::SharedFromSelf;
|
||||
use r9_macro_derive::SharedFromSelf;
|
||||
use r9_macro_derive::Singleton;
|
||||
use r9::Queue;
|
||||
use f9::app::App;
|
||||
use f9::app::HttpContext;
|
||||
use crate::listener::WsListener;
|
||||
use crate::upstream::UpStreamMgr;
|
||||
use bytes::BytesMut;
|
||||
//use crate::ss;
|
||||
|
||||
pub struct DownStreamPack {
|
||||
data: bytes::BytesMut,
|
||||
entry: Rc::<RefCell::<r9::ListHead<DownStreamPack>>>,
|
||||
}
|
||||
|
||||
#[derive(SharedFromSelf)]
|
||||
#[derive(Singleton)]
|
||||
pub struct UserApp {
|
||||
_self_wp: Weak::<RefCell::<Self>>,
|
||||
net_msg_queue: Rc::<RefCell::<r9::Queue<DownStreamPack>>>,
|
||||
}
|
||||
|
||||
impl f9::app::UserApp for UserApp {
|
||||
@ -44,7 +52,10 @@ impl f9::app::UserApp for UserApp {
|
||||
}
|
||||
|
||||
fn update(&mut self) {
|
||||
self.net_msg_queue.borrow_mut().fetch();
|
||||
if self.net_msg_queue.borrow_mut().empty() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fn uninit(&mut self) {
|
||||
@ -59,12 +70,19 @@ impl f9::app::UserApp for UserApp {
|
||||
|
||||
impl UserApp {
|
||||
|
||||
pub fn test(&mut self) {
|
||||
pub fn add_down_stream_pack(&mut self, data: bytes::BytesMut) {
|
||||
let node = Rc::new(RefCell::new(DownStreamPack{
|
||||
data: data,
|
||||
entry: r9::ListHead::< crate::app::user_app::DownStreamPack>::new_node(Default::default()),
|
||||
}));
|
||||
node.borrow_mut().entry = r9::ListHead::< crate::app::user_app::DownStreamPack>::new_node(Rc::downgrade(&node));
|
||||
self.net_msg_queue.borrow_mut().push(&node.borrow_mut().entry);
|
||||
}
|
||||
|
||||
pub fn new() -> Self {
|
||||
let p = UserApp{
|
||||
_self_wp: Default::default(),
|
||||
net_msg_queue: r9::Queue::<DownStreamPack>::new(),
|
||||
};
|
||||
return p;
|
||||
}
|
||||
|
@ -90,9 +90,8 @@ impl MyWs {
|
||||
println!("recv buf_len:{0}", tmp_bytes.len());
|
||||
}
|
||||
{
|
||||
UserApp::instance().borrow_mut().test();
|
||||
Arc::downgrade(&mut self.send_queue).upgrade().unwrap().lock().unwrap().borrow_mut().insert(0, tmp_bytes);
|
||||
//Arc::downgrade(&mut self.send_queue).upgrade().unwrap().lock().unwrap().borrow_mut().push(tmp_bytes);
|
||||
UserApp::instance().borrow_mut().add_down_stream_pack(tmp_bytes);
|
||||
//Arc::downgrade(&mut self.send_queue).upgrade().unwrap().lock().unwrap().borrow_mut().insert(0, tmp_bytes);
|
||||
}
|
||||
offset += (pack_len as usize) + 12;
|
||||
}
|
||||
@ -237,6 +236,10 @@ async fn index(req: HttpRequest, stream: web::Payload, data: web::Data<AppStateW
|
||||
recv_queue: Default::default(),
|
||||
//addr: Default::default(),
|
||||
};
|
||||
{
|
||||
let mut tmp_bytes = BytesMut::with_capacity((16) as usize);
|
||||
UserApp::instance().borrow_mut().add_down_stream_pack(tmp_bytes);
|
||||
}
|
||||
{
|
||||
let mut down_stream = TcpStream::connect("192.168.100.39:7616").await?;
|
||||
down_stream.set_nodelay(true);
|
||||
@ -358,6 +361,7 @@ fn main() {
|
||||
});
|
||||
println!("hello2");
|
||||
});
|
||||
println!("hello3");
|
||||
}
|
||||
App::run();
|
||||
App::uninit();
|
||||
|
2
third_party/librust
vendored
2
third_party/librust
vendored
@ -1 +1 @@
|
||||
Subproject commit ea6e02768dc8af5db4d781898336b5961f421baf
|
||||
Subproject commit bf7c30e822a0b6190b079c303a9932d334841a3c
|
Loading…
x
Reference in New Issue
Block a user