pub async fn auth_ws(
        request: &hyper::Request<hyper::Body>,
        states: &Arc<Mutex<StatesList>>,
    ) -> bool {
        let url = request.uri();
        // Create a URL to so the parameters can be queried
        let url = url::Url::parse(&format!("ws://locahost{}", &url.to_string())).unwrap();
        // Get tha parameters
        let parameters: HashMap<String, String> = url.query_pairs().into_owned().collect();
        let token = parameters.get("token");
        let state_id = parameters.get("state_id");

        if let (Some(token), Some(state_id)) = (token, state_id) {
            let state_id = state_id.parse::<u8>();
            if let Ok(state_id) = state_id {
                if let Some(state) = states.lock().await.get_state_by_id(state_id) {
                    // If found, then make sure the token is valid
                    state.lock().await.has_token(token)
                } else {
                    false
                }
            } else {
                false
            }
        } else {
            false
        }
    }
/// Authenticate the Websocket by querying the URL
///
/// * `request`           - The Hyper request
/// * `states`            - A States list
Authenticate the Websocket by querying the URL
`request`           - The Hyper request
`states`            - A States list
Authenticate the Websocket by querying the URL ` request ` - The Hyper request ` states ` - A States list
pub async fn auth_ws(
        request: &hyper::Request<hyper::Body>,
        states: &Arc<Mutex<StatesList>>,
    ) -> bool {
        let url = request.uri();
        // Create a URL to so the parameters can be queried
        let url = url::Url::parse(&format!("ws://locahost{}", &url.to_string())).unwrap();
        // Get tha parameters
        let parameters: HashMap<String, String> = url.query_pairs().into_owned().collect();
        let token = parameters.get("token");
        let state_id = parameters.get("state_id");
        if let (Some(token), Some(state_id)) = (token, state_id) {
            let state_id = state_id.parse::<u8>();
            if let Ok(state_id) = state_id {
                if let Some(state) = states.lock().await.get_state_by_id(state_id) {
                    // If found, then make sure the token is valid
                    state.lock().await.has_token(token)
                } else {
                    false
                }
            } else {
                false
            }
        } else {
            false
        }
    }
pub async fn auth_ws ( request : & hyper :: Request < hyper :: Body > , states : & Arc < Mutex < StatesList > > , ) -> bool { let url = request . uri ( ) ; // Create a URL to so the parameters can be queried let url = url :: Url :: parse ( & format ! ( " " url to_string ( ) ) ) . unwrap ( ) ; // Get tha parameters let parameters : HashMap < String , String > = url . query_pairs ( ) . into_owned ( ) . collect ( ) ; let token = parameters . get ( " " ) ; let state_id = parameters . get ( " " ) ; if let ( Some ( token ) , Some ( state_id ) ) = ( token , state_id ) { let state_id = state_id . parse :: < u8 > ( ) ; if let Ok ( state_id ) = state_id { if let Some ( state ) = states . lock ( ) . await . get_state_by_id ( state_id ) { // If found, then make sure the token is valid state . lock ( ) . await . has_token ( token ) } else { false } } else { false } } else { false } }
Authenticate the Websocket by querying the URL
 `request`           - The Hyper request
 `states`            - A States list
Authenticate the Websocket by querying the URL ` request ` - The Hyper request ` states ` - A States list
request
&hyper::Request<hyper::Body>
states
&Arc<Mutex<StatesList>>