mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Close websockets properly when closing connection
This commit is contained in:
@ -24,7 +24,8 @@ use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::user::UserID;
|
||||
use crate::data::user_ws_message::UserWsMessage;
|
||||
use crate::data::user_ws_request_handler::{UserWsRequestHandler, UserWsResponseType};
|
||||
use crate::helpers::account_helper;
|
||||
use crate::helpers::{account_helper, events_helper};
|
||||
use crate::helpers::events_helper::Event;
|
||||
use crate::utils::crypt_utils::rand_str;
|
||||
use crate::utils::date_utils::time;
|
||||
|
||||
@ -570,5 +571,17 @@ pub fn disconnect_user_from_all_sockets(user_id: &UserID) -> Res {
|
||||
c.do_send(WsCloseConnection {});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Events handler
|
||||
pub fn handle_event(e: &events_helper::Event) -> Res {
|
||||
match e {
|
||||
Event::DestroyedLoginToken(user_id, client) => {
|
||||
disconnect_user_from_client(user_id, client)?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user