This commit is contained in:
azw 2023-11-11 06:34:48 +00:00
parent 18521debbc
commit f0f9c4cb5c

View File

@ -58,7 +58,7 @@ struct IMMsgNode {
struct HttpContext {
id: u64,
req: HttpRequest,
//req: &HttpRequest,
add_tick: i64,
handled: bool,
rsp: String
@ -69,14 +69,15 @@ async fn index(data: Data<Arc::<AppState>>, req: HttpRequest) -> impl Responder
let context = Arc::new(
Mutex::new(HttpContext{
id: 0,
req: req,
//req: &req,
add_tick: 0,
handled: false,
rsp: "".to_string()
})
);
{
//data.request.lock();
let v = &mut data.request.lock().unwrap();
(*v).push(context.clone());
}
{
while !context.lock().unwrap().handled {
@ -125,7 +126,7 @@ impl App {
im_mutex: Mutex::new(1),
webapp_state: Arc::new(
AppState{
//request: Default::default()
request: Default::default()
}
),
_self_wp: Default::default(),
@ -158,6 +159,7 @@ impl App {
crate::Timer::instance().borrow_mut().update();
std::thread::sleep(Duration::from_millis(1));
self.dispatch_immsg();
self.dispatch_httprequest();
}
}
@ -231,6 +233,24 @@ impl App {
}
}
fn dispatch_httprequest(&mut self) {
{
let v = &mut self.webapp_state.request.lock().unwrap();
if v.len() > 0 {
let c = v.pop();
match c {
Some(v) => {
v.lock().unwrap().rsp = "dsafsf".to_string();
v.lock().unwrap().handled = true;
}
None => {
}
}
}
}
}
fn init_http_server(&mut self) {
let (tx, _) = mpsc::channel();