1
This commit is contained in:
parent
18521debbc
commit
f0f9c4cb5c
@ -58,7 +58,7 @@ struct IMMsgNode {
|
|||||||
|
|
||||||
struct HttpContext {
|
struct HttpContext {
|
||||||
id: u64,
|
id: u64,
|
||||||
req: HttpRequest,
|
//req: &HttpRequest,
|
||||||
add_tick: i64,
|
add_tick: i64,
|
||||||
handled: bool,
|
handled: bool,
|
||||||
rsp: String
|
rsp: String
|
||||||
@ -69,14 +69,15 @@ async fn index(data: Data<Arc::<AppState>>, req: HttpRequest) -> impl Responder
|
|||||||
let context = Arc::new(
|
let context = Arc::new(
|
||||||
Mutex::new(HttpContext{
|
Mutex::new(HttpContext{
|
||||||
id: 0,
|
id: 0,
|
||||||
req: req,
|
//req: &req,
|
||||||
add_tick: 0,
|
add_tick: 0,
|
||||||
handled: false,
|
handled: false,
|
||||||
rsp: "".to_string()
|
rsp: "".to_string()
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
{
|
{
|
||||||
//data.request.lock();
|
let v = &mut data.request.lock().unwrap();
|
||||||
|
(*v).push(context.clone());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
while !context.lock().unwrap().handled {
|
while !context.lock().unwrap().handled {
|
||||||
@ -125,7 +126,7 @@ impl App {
|
|||||||
im_mutex: Mutex::new(1),
|
im_mutex: Mutex::new(1),
|
||||||
webapp_state: Arc::new(
|
webapp_state: Arc::new(
|
||||||
AppState{
|
AppState{
|
||||||
//request: Default::default()
|
request: Default::default()
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
_self_wp: Default::default(),
|
_self_wp: Default::default(),
|
||||||
@ -158,6 +159,7 @@ impl App {
|
|||||||
crate::Timer::instance().borrow_mut().update();
|
crate::Timer::instance().borrow_mut().update();
|
||||||
std::thread::sleep(Duration::from_millis(1));
|
std::thread::sleep(Duration::from_millis(1));
|
||||||
self.dispatch_immsg();
|
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) {
|
fn init_http_server(&mut self) {
|
||||||
let (tx, _) = mpsc::channel();
|
let (tx, _) = mpsc::channel();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user