/// Method waits for client state changes.
/// If an error occured during authorization flow, you receive [AuthorizationState](crate::types::authorization_state::AuthorizationState) on which it happened.
/// You have to setup [channel](tokio::sync::mpsc::channel) by call [Client::builder().with_auth_state_channel(...)](Client::builder().with_auth_state_channel(...))
Method waits for client state changes.
Method waits for client state changes .
pub async fn wait_auth_state_change(&self, client: &Client<T>) -> RTDResult<StateMessage> {
        let client_id = client.get_client_id()?;
        match self.clients.read().await.get(&client_id) {
            None => {Err(RTDError::BadRequest("client not authorized yet"))}
            Some(v) => {
                match v.pub_state_message_receiver() {
                    None => {Err(RTDError::BadRequest("state receiver not specified, need to call `Client::builder().with_auth_state_channel(...) before Worker::bind_client(...)"))}
                    Some(rec) => {
                        let state = rec.lock().await.recv().await.ok_or(RTDError::Internal("can't receive state: channel closed"))?;
                        Ok(state)
                    }
                }
            }
        }
    }
pub async fn wait_auth_state_change ( & self , client : & Client < T > ) -> RTDResult < StateMessage > { let client_id = client . get_client_id ( ) ? ; match self . clients . read ( ) . await . get ( & client_id ) { None => { Err ( RTDError :: BadRequest ( " " ) ) } Some ( v ) => { match v . pub_state_message_receiver ( ) { None => { Err ( RTDError :: BadRequest ( " " ) ) } Some ( rec ) => { let state = rec . lock ( ) . await . recv ( ) . await . ok_or ( RTDError :: Internal ( " " ) ) ? ; Ok ( state ) } } } } }
Method waits for client state changes.
Method waits for client state changes .
&self
client
&Client<T>