pub fn create(conduit: ConduitHandle) -> Arc<Mutex<SwitchboardImpl>> {
        let (cancel_listen_tx, mut cancel_listen_rx) =
            futures::channel::mpsc::unbounded::<ListenSessionInfo>();

        let (conduit_sender, mut conduit_receiver) = block_on(conduit.lock()).create_waypoint();

        let switchboard = Arc::new(Mutex::new(Self {
            next_session_id: 0,
            next_action_id: 0,
            conduit_sender: conduit_sender,
            listen_cancellation_sender: cancel_listen_tx,
            request_responders: HashMap::new(),
            listeners: HashMap::new(),
        }));

        {
            let switchboard_clone = switchboard.clone();
            fasync::spawn(async move {
                while let Some(conduit_data) = conduit_receiver.next().await {
                    if let ConduitData::Event(event) = conduit_data {
                        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 switchboard;
    }
/// 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.
Creates a new SwitchboardImpl which will return the instance along with a sender to provide events in response to the actions sent .
pub fn create(conduit: ConduitHandle) -> Arc<Mutex<SwitchboardImpl>> {
        let (cancel_listen_tx, mut cancel_listen_rx) =
            futures::channel::mpsc::unbounded::<ListenSessionInfo>();
        let (conduit_sender, mut conduit_receiver) = block_on(conduit.lock()).create_waypoint();
        let switchboard = Arc::new(Mutex::new(Self {
            next_session_id: 0,
            next_action_id: 0,
            conduit_sender: conduit_sender,
            listen_cancellation_sender: cancel_listen_tx,
            request_responders: HashMap::new(),
            listeners: HashMap::new(),
        }));
        {
            let switchboard_clone = switchboard.clone();
            fasync::spawn(async move {
                while let Some(conduit_data) = conduit_receiver.next().await {
                    if let ConduitData::Event(event) = conduit_data {
                        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 switchboard;
    }
pub fn create ( conduit : ConduitHandle ) -> Arc < Mutex < SwitchboardImpl > > { let ( cancel_listen_tx , mut cancel_listen_rx ) = futures :: channel :: mpsc :: unbounded :: < ListenSessionInfo > ( ) ; let ( conduit_sender , mut conduit_receiver ) = block_on ( conduit . lock ( ) ) . create_waypoint ( ) ; let switchboard = Arc :: new ( Mutex :: new ( Self { next_session_id : 0 , next_action_id : 0 , conduit_sender : conduit_sender , listen_cancellation_sender : cancel_listen_tx , request_responders : HashMap :: new ( ) , listeners : HashMap :: new ( ) , } ) ) ; { let switchboard_clone = switchboard . clone ( ) ; fasync :: spawn ( async move { while let Some ( conduit_data ) = conduit_receiver . next ( ) . await { if let ConduitData :: Event ( event ) = conduit_data { 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 switchboard ; }
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 .
conduit
ConduitHandle
conduit
ConduitHandle