Implement disconnect specific client ID
This commit is contained in:
		@@ -64,7 +64,16 @@ pub async fn ws_handler(
 | 
				
			|||||||
                };
 | 
					                };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                match msg {
 | 
					                match msg {
 | 
				
			||||||
                    WsMessage::CloseClientSession(_) => todo!(),
 | 
					                    WsMessage::CloseClientSession(id)  => {
 | 
				
			||||||
 | 
					                        if let Some(client) = &auth.client {
 | 
				
			||||||
 | 
					                            if client.id == id {
 | 
				
			||||||
 | 
					                                log::info!(
 | 
				
			||||||
 | 
					                                "closing client session {id:?} of user {:?} as requested", auth.user.user_id
 | 
				
			||||||
 | 
					                            );
 | 
				
			||||||
 | 
					                            break None;
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        }
 | 
				
			||||||
 | 
					                    },
 | 
				
			||||||
                    WsMessage::CloseAllUserSessions(userid) => {
 | 
					                    WsMessage::CloseAllUserSessions(userid) => {
 | 
				
			||||||
                        if userid == auth.user.user_id {
 | 
					                        if userid == auth.user.user_id {
 | 
				
			||||||
                            log::info!(
 | 
					                            log::info!(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -138,7 +138,10 @@ pub async fn home(
 | 
				
			|||||||
            config.clients.retain(|c| c.id != delete_client_id);
 | 
					            config.clients.retain(|c| c.id != delete_client_id);
 | 
				
			||||||
            config.save().await?;
 | 
					            config.save().await?;
 | 
				
			||||||
            success_message = Some("The client was successfully deleted!".to_string());
 | 
					            success_message = Some("The client was successfully deleted!".to_string());
 | 
				
			||||||
            // TODO : close connections with given id
 | 
					
 | 
				
			||||||
 | 
					            if let Err(e) = tx.send(WsMessage::CloseClientSession(delete_client_id)) {
 | 
				
			||||||
 | 
					                log::error!("Failed to send CloseClientSession: {}", e);
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user