pub async fn skills_answerable(
        &mut self,
        ids: &[String],
        request: RequestData,
        client: ClientData,
    ) -> Vec<MsgNotification> {
        // TODO: Respond to the notification
        async fn send_msg(
            self_send: &mut mpsc::Sender<(String, Vec<u8>)>,
            id: &str,
            request: RequestData,
            request_id: RequestId,
            client: ClientData,
            pending_can_you: &SharedPending<f32>,
        ) -> Result<MsgNotification, Error> {
            let msg = MsgSkillRequest {
                client,
                request_id,
                request,
            };
            let data = rmp_serde::to_vec(&msg).unwrap();
            self_send.send((id.into(), data)).await.unwrap();

            let (sender, receiver) = oneshot::channel();
            pending_can_you.lock().await.insert(request_id, sender);
            let a = receiver.await.unwrap();

            Ok(MsgNotification {
                skill_id: id.to_string(),
                data: vec![msg_notification::Data::CanYouAnswer {
                    request_id,
                    confidence: a,
                }],
            })
        }

        let mut answers = Vec::new();
        let new_id = self.get_id();
        for id in ids {
            match send_msg(
                &mut self.self_send,
                id,
                request.clone(),
                new_id,
                client.clone(),
                &self.pending_can_you,
            )
            .await
            {
                Ok(resp) => {
                    println!("We received the notification: {:?}", resp);
                    answers.push(resp);
                }
                Err(e) => {
                    // TODO: What to do with the errors?
                    println!("Error receiving notifications: {:?}", e);
                }
            }
        }

        answers
    }
/// Returns how confident skills registered for some request are in being able to handle it
Returns how confident skills registered for some request are in being able to handle it
Returns how confident skills registered for some request are in being able to handle it
pub async fn skills_answerable(
        &mut self,
        ids: &[String],
        request: RequestData,
        client: ClientData,
    ) -> Vec<MsgNotification> {
        // TODO: Respond to the notification
        async fn send_msg(
            self_send: &mut mpsc::Sender<(String, Vec<u8>)>,
            id: &str,
            request: RequestData,
            request_id: RequestId,
            client: ClientData,
            pending_can_you: &SharedPending<f32>,
        ) -> Result<MsgNotification, Error> {
            let msg = MsgSkillRequest {
                client,
                request_id,
                request,
            };
            let data = rmp_serde::to_vec(&msg).unwrap();
            self_send.send((id.into(), data)).await.unwrap();
            let (sender, receiver) = oneshot::channel();
            pending_can_you.lock().await.insert(request_id, sender);
            let a = receiver.await.unwrap();
            Ok(MsgNotification {
                skill_id: id.to_string(),
                data: vec![msg_notification::Data::CanYouAnswer {
                    request_id,
                    confidence: a,
                }],
            })
        }
        let mut answers = Vec::new();
        let new_id = self.get_id();
        for id in ids {
            match send_msg(
                &mut self.self_send,
                id,
                request.clone(),
                new_id,
                client.clone(),
                &self.pending_can_you,
            )
            .await
            {
                Ok(resp) => {
                    println!("We received the notification: {:?}", resp);
                    answers.push(resp);
                }
                Err(e) => {
                    // TODO: What to do with the errors?
                    println!("Error receiving notifications: {:?}", e);
                }
            }
        }
        answers
    }
pub async fn skills_answerable ( & mut self , ids : & [ String ] , request : RequestData , client : ClientData , ) -> Vec < MsgNotification > { // TODO: Respond to the notification async fn send_msg ( self_send : & mut mpsc :: Sender < ( String , Vec < u8 > ) > , id : & str , request : RequestData , request_id : RequestId , client : ClientData , pending_can_you : & SharedPending < f32 > , ) -> Result < MsgNotification , Error > { let msg = MsgSkillRequest { client , request_id , request , } ; let data = rmp_serde :: to_vec ( & msg ) . unwrap ( ) ; self_send . send ( ( id . into ( ) , data ) ) . await . unwrap ( ) ; let ( sender , receiver ) = oneshot :: channel ( ) ; pending_can_you . lock ( ) . await . insert ( request_id , sender ) ; let a = receiver . await . unwrap ( ) ; Ok ( MsgNotification { skill_id : id . to_string ( ) , data : vec ! [ msg_notification Data CanYouAnswer { request_id confidence a } ] , } ) } let mut answers = Vec :: new ( ) ; let new_id = self . get_id ( ) ; for id in ids { match send_msg ( & mut self . self_send , id , request . clone ( ) , new_id , client . clone ( ) , & self . pending_can_you , ) . await { Ok ( resp ) => { println ! ( " " resp ) ; answers . push ( resp ) ; } Err ( e ) => { // TODO: What to do with the errors? println ! ( " " e ) ; } } } answers }
Returns how confident skills registered for some request are in being able to handle it
Returns how confident skills registered for some request are in being able to handle it
&mut self
ids
&[String]
request
RequestData
client
ClientData