mirror of
https://github.com/Xevion/dynamic-preauth.git
synced 2025-12-11 12:07:12 -06:00
use send_state, fix sending state without tx ready, switch to u32 for download token
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -102,10 +102,7 @@ async fn handle_socket(session_id: usize, websocket: WebSocket) {
|
||||
.expect("Unable to get session");
|
||||
session.tx = Some(tx_channel);
|
||||
|
||||
session.send_message(OutgoingMessage::State {
|
||||
id: session_id,
|
||||
session: session.clone(),
|
||||
});
|
||||
session.send_state();
|
||||
session.send_message(executable_message);
|
||||
|
||||
// Handle incoming messages
|
||||
@@ -193,6 +190,13 @@ pub async fn download(req: &mut Request, res: &mut Response, depot: &mut Depot)
|
||||
"Content-Type",
|
||||
HeaderValue::from_static("application/octet-stream"),
|
||||
);
|
||||
|
||||
// Don't try to send state if somehow the session has not connected
|
||||
if session.tx.is_some() {
|
||||
session.send_state();
|
||||
} else {
|
||||
tracing::warn!("Download being made without any connection websocket");
|
||||
}
|
||||
}
|
||||
|
||||
#[handler]
|
||||
|
||||
Reference in New Issue
Block a user