async fn inner_join_realm(
        &mut self,
        realm: String,
        authentication_methods: Vec<AuthenticationMethod>,
        authentication_id: Option<String>,
        on_challenge_handler: Option<AuthenticationChallengeHandler<'a>>,
    ) -> Result<(), WampError> {
        // Make sure the event loop is ready to process requests
        if let ClientState::NoEventLoop = self.get_cur_status() {
            debug!("Called join_realm() before th event loop is ready... Waiting...");
            self.wait_for_status_change().await;
        }

        // Make sure we are still connected to a server
        if !self.is_connected() {
            return Err(From::from(
                "The client is currently not connected".to_string(),
            ));
        }

        // Make sure we arent already part of a realm
        if self.session_id.is_some() {
            return Err(From::from(format!(
                "join_realm('{}') : Client already joined to a realm",
                realm
            )));
        }

        // Send a request for the core to perform the action
        let (res_sender, res) = oneshot::channel();
        if let Err(e) = self.ctl_channel.send(Request::Join {
            uri: realm,
            roles: self.config.roles.clone(),
            agent_str: if self.config.agent.is_empty() {
                Some(self.config.agent.clone())
            } else {
                None
            },
            authentication_methods,
            authentication_id,
            on_challenge_handler,
            res: res_sender,
        }) {
            return Err(From::from(format!(
                "Core never received our request : {}",
                e
            )));
        }

        // Wait for the request results
        let (session_id, mut server_roles) = match res.await {
            Ok(r) => r?,
            Err(e) => {
                return Err(From::from(format!(
                    "Core never returned a response : {}",
                    e
                )))
            }
        };

        // Add the server roles
        self.server_roles.drain();
        for (role, _) in server_roles.drain().take(1) {
            self.server_roles.insert(role);
        }

        // Set the current session
        self.session_id = Some(session_id);
        debug!("Connected with session_id {} !", session_id);

        Ok(())
    }
/// Attempts to join a realm and start a session with the server.
///
/// See [`join_realm_with_authentication`] method for more details.
Attempts to join a realm and start a session with the server.
See [`join_realm_with_authentication`] method for more details.
Attempts to join a realm and start a session with the server . See [ ` join_realm_with_authentication ` ] method for more details .
async fn inner_join_realm(
        &mut self,
        realm: String,
        authentication_methods: Vec<AuthenticationMethod>,
        authentication_id: Option<String>,
        on_challenge_handler: Option<AuthenticationChallengeHandler<'a>>,
    ) -> Result<(), WampError> {
        // Make sure the event loop is ready to process requests
        if let ClientState::NoEventLoop = self.get_cur_status() {
            debug!("Called join_realm() before th event loop is ready... Waiting...");
            self.wait_for_status_change().await;
        }
        // Make sure we are still connected to a server
        if !self.is_connected() {
            return Err(From::from(
                "The client is currently not connected".to_string(),
            ));
        }
        // Make sure we arent already part of a realm
        if self.session_id.is_some() {
            return Err(From::from(format!(
                "join_realm('{}') : Client already joined to a realm",
                realm
            )));
        }
        // Send a request for the core to perform the action
        let (res_sender, res) = oneshot::channel();
        if let Err(e) = self.ctl_channel.send(Request::Join {
            uri: realm,
            roles: self.config.roles.clone(),
            agent_str: if self.config.agent.is_empty() {
                Some(self.config.agent.clone())
            } else {
                None
            },
            authentication_methods,
            authentication_id,
            on_challenge_handler,
            res: res_sender,
        }) {
            return Err(From::from(format!(
                "Core never received our request : {}",
                e
            )));
        }
        // Wait for the request results
        let (session_id, mut server_roles) = match res.await {
            Ok(r) => r?,
            Err(e) => {
                return Err(From::from(format!(
                    "Core never returned a response : {}",
                    e
                )))
            }
        };
        // Add the server roles
        self.server_roles.drain();
        for (role, _) in server_roles.drain().take(1) {
            self.server_roles.insert(role);
        }
        // Set the current session
        self.session_id = Some(session_id);
        debug!("Connected with session_id {} !", session_id);
        Ok(())
    }
async fn inner_join_realm ( & mut self , realm : String , authentication_methods : Vec < AuthenticationMethod > , authentication_id : Option < String > , on_challenge_handler : Option < AuthenticationChallengeHandler < ' a > > , ) -> Result < ( ) , WampError > { // Make sure the event loop is ready to process requests if let ClientState :: NoEventLoop = self . get_cur_status ( ) { debug ! ( " " ) ; self . wait_for_status_change ( ) . await ; } // Make sure we are still connected to a server if ! self . is_connected ( ) { return Err ( From :: from ( " " . to_string ( ) , ) ) ; } // Make sure we arent already part of a realm if self . session_id . is_some ( ) { return Err ( From :: from ( format ! ( " " realm ) ) ) ; } // Send a request for the core to perform the action let ( res_sender , res ) = oneshot :: channel ( ) ; if let Err ( e ) = self . ctl_channel . send ( Request :: Join { uri : realm , roles : self . config . roles . clone ( ) , agent_str : if self . config . agent . is_empty ( ) { Some ( self . config . agent . clone ( ) ) } else { None } , authentication_methods , authentication_id , on_challenge_handler , res : res_sender , } ) { return Err ( From :: from ( format ! ( " " e ) ) ) ; } // Wait for the request results let ( session_id , mut server_roles ) = match res . await { Ok ( r ) => r ? , Err ( e ) => { return Err ( From :: from ( format ! ( " " e ) ) ) } } ; // Add the server roles self . server_roles . drain ( ) ; for ( role , _ ) in server_roles . drain ( ) . take ( 1 ) { self . server_roles . insert ( role ) ; } // Set the current session self . session_id = Some ( session_id ) ; debug ! ( " " session_id ) ; Ok ( ( ) ) }
Attempts to join a realm and start a session with the server.
Attempts to join a realm and start a session with the server .
&mut self
realm
String
authentication_methods
Vec<AuthenticationMethod>
authentication_id
Option<String>
on_challenge_handler
Option<AuthenticationChallengeHandler<'a>>