pub async fn create(
        registry_messenger_factory: RegistryMessengerFactory,
        inspect_node: inspect::Node,
    ) -> Result<SwitchboardClient, Error> {
        let (cancel_listen_tx, mut cancel_listen_rx) =
            futures::channel::mpsc::unbounded::<ListenSessionInfo>();
        let messenger_result = registry_messenger_factory
            .create(MessengerType::Addressable(Address::Switchboard))
            .await;

        if let Err(error) = messenger_result {
            return Err(Error::new(error));
        }

        let (registry_messenger_client, mut receptor) = messenger_result.unwrap();

        let switchboard = Arc::new(Mutex::new(Self {
            next_session_id: 0,
            next_action_id: 0,
            listen_cancellation_sender: cancel_listen_tx,
            listeners: HashMap::new(),
            registry_messenger_client: registry_messenger_client,
            last_requests: VecDeque::with_capacity(INSPECT_REQUESTS_COUNT),
            inspect_node: inspect_node,
        }));

        {
            let switchboard_clone = switchboard.clone();
            fasync::spawn(async move {
                while let Ok(message_event) = receptor.watch().await {
                    // Wait for response
                    if let MessageEvent::Message(Payload::Event(event), _) = message_event {
                        switchboard_clone.lock().await.process_event(event);
                    }
                }
            });
        }

        {
            let switchboard_clone = switchboard.clone();
            fasync::spawn(async move {
                while let Some(info) = cancel_listen_rx.next().await {
                    switchboard_clone.lock().await.stop_listening(info);
                }
            });
        }

        return Ok(SwitchboardClient::new(&(switchboard as SwitchboardHandle)));
    }
/// Creates a new SwitchboardImpl, which will return the instance along with
/// a sender to provide events in response to the actions sent.
///
/// Requests will be recorded to the given inspect node.
Creates a new SwitchboardImpl, which will return the instance along with
a sender to provide events in response to the actions sent.

Requests will be recorded to the given inspect node.
Creates a new SwitchboardImpl which will return the instance along with a sender to provide events in response to the actions sent . Requests will be recorded to the given inspect node .
pub async fn create(
        registry_messenger_factory: RegistryMessengerFactory,
        inspect_node: inspect::Node,
    ) -> Result<SwitchboardClient, Error> {
        let (cancel_listen_tx, mut cancel_listen_rx) =
            futures::channel::mpsc::unbounded::<ListenSessionInfo>();
        let messenger_result = registry_messenger_factory
            .create(MessengerType::Addressable(Address::Switchboard))
            .await;
        if let Err(error) = messenger_result {
            return Err(Error::new(error));
        }
        let (registry_messenger_client, mut receptor) = messenger_result.unwrap();
        let switchboard = Arc::new(Mutex::new(Self {
            next_session_id: 0,
            next_action_id: 0,
            listen_cancellation_sender: cancel_listen_tx,
            listeners: HashMap::new(),
            registry_messenger_client: registry_messenger_client,
            last_requests: VecDeque::with_capacity(INSPECT_REQUESTS_COUNT),
            inspect_node: inspect_node,
        }));
        {
            let switchboard_clone = switchboard.clone();
            fasync::spawn(async move {
                while let Ok(message_event) = receptor.watch().await {
                    // Wait for response
                    if let MessageEvent::Message(Payload::Event(event), _) = message_event {
                        switchboard_clone.lock().await.process_event(event);
                    }
                }
            });
        }
        {
            let switchboard_clone = switchboard.clone();
            fasync::spawn(async move {
                while let Some(info) = cancel_listen_rx.next().await {
                    switchboard_clone.lock().await.stop_listening(info);
                }
            });
        }
        return Ok(SwitchboardClient::new(&(switchboard as SwitchboardHandle)));
    }
pub async fn create ( registry_messenger_factory : RegistryMessengerFactory , inspect_node : inspect :: Node , ) -> Result < SwitchboardClient , Error > { let ( cancel_listen_tx , mut cancel_listen_rx ) = futures :: channel :: mpsc :: unbounded :: < ListenSessionInfo > ( ) ; let messenger_result = registry_messenger_factory . create ( MessengerType :: Addressable ( Address :: Switchboard ) ) . await ; if let Err ( error ) = messenger_result { return Err ( Error :: new ( error ) ) ; } let ( registry_messenger_client , mut receptor ) = messenger_result . unwrap ( ) ; let switchboard = Arc :: new ( Mutex :: new ( Self { next_session_id : 0 , next_action_id : 0 , listen_cancellation_sender : cancel_listen_tx , listeners : HashMap :: new ( ) , registry_messenger_client : registry_messenger_client , last_requests : VecDeque :: with_capacity ( INSPECT_REQUESTS_COUNT ) , inspect_node : inspect_node , } ) ) ; { let switchboard_clone = switchboard . clone ( ) ; fasync :: spawn ( async move { while let Ok ( message_event ) = receptor . watch ( ) . await { // Wait for response if let MessageEvent :: Message ( Payload :: Event ( event ) , _ ) = message_event { switchboard_clone . lock ( ) . await . process_event ( event ) ; } } } ) ; } { let switchboard_clone = switchboard . clone ( ) ; fasync :: spawn ( async move { while let Some ( info ) = cancel_listen_rx . next ( ) . await { switchboard_clone . lock ( ) . await . stop_listening ( info ) ; } } ) ; } return Ok ( SwitchboardClient :: new ( & ( switchboard as SwitchboardHandle ) ) ) ; }
Creates a new SwitchboardImpl, which will return the instance along with
a sender to provide events in response to the actions sent.
Creates a new SwitchboardImpl which will return the instance along with a sender to provide events in response to the actions sent .
registry_messenger_factory
RegistryMessengerFactory
inspect_node
inspect::Node
registry_messenger_factory
RegistryMessengerFactory
inspect_node
inspect::Node