pub fn new_l2cap_connection(&mut self, id: PeerId, l2cap: Channel) -> Result<(), Error> {
        if self.is_active_session(&id) {
            return Err(format_err!("RFCOMM Session already exists with peer {:?}", id));
        }
        info!("Received new l2cap connection from peer {:?}", id);

        // Create a new RFCOMM Session with the provided `channel_opened_callback` which will be
        // called anytime an RFCOMM channel is created. Opened RFCOMM channels will be delivered
        // to the `clients` of the `RfcommServer`.
        let clients = self.clients.clone();
        let channel_opened_callback = Box::new(move |server_channel, channel| {
            let peer_id = id;
            let clients = clients.clone();
            async move { clients.deliver_channel(peer_id, server_channel, channel).await }.boxed()
        });
        let mut session = Session::create(id, l2cap, channel_opened_callback);
        let _ = session.iattach(&self.inspect, inspect::unique_name("peer_"));
        let closed_fut = session.finished();
        if self.sessions.insert(id, session).is_some() {
            warn!("Overwriting existing RFCOMM session");
        }

        // Task eagerly removes the Session from the set of active sessions upon termination.
        let detached_session = self.sessions.get(&id).expect("just inserted");
        fasync::Task::spawn(async move {
            let _ = closed_fut.await;
            detached_session.detach();
        })
        .detach();

        Ok(())
    }
/// Handles an incoming L2CAP connection from the remote peer.
///
/// If there is already an active session established with this peer, returns an Error
/// as there can only be one active session per peer.
/// Otherwise, creates and stores a new session over the provided `l2cap` channel.
Handles an incoming L2CAP connection from the remote peer.
If there is already an active session established with this peer, returns an Error
as there can only be one active session per peer.
Otherwise, creates and stores a new session over the provided `l2cap` channel.
Handles an incoming L2CAP connection from the remote peer . If there is already an active session established with this peer returns an Error as there can only be one active session per peer . Otherwise creates and stores a new session over the provided ` l2cap ` channel .
pub fn new_l2cap_connection(&mut self, id: PeerId, l2cap: Channel) -> Result<(), Error> {
        if self.is_active_session(&id) {
            return Err(format_err!("RFCOMM Session already exists with peer {:?}", id));
        }
        info!("Received new l2cap connection from peer {:?}", id);
        // Create a new RFCOMM Session with the provided `channel_opened_callback` which will be
        // called anytime an RFCOMM channel is created. Opened RFCOMM channels will be delivered
        // to the `clients` of the `RfcommServer`.
        let clients = self.clients.clone();
        let channel_opened_callback = Box::new(move |server_channel, channel| {
            let peer_id = id;
            let clients = clients.clone();
            async move { clients.deliver_channel(peer_id, server_channel, channel).await }.boxed()
        });
        let mut session = Session::create(id, l2cap, channel_opened_callback);
        let _ = session.iattach(&self.inspect, inspect::unique_name("peer_"));
        let closed_fut = session.finished();
        if self.sessions.insert(id, session).is_some() {
            warn!("Overwriting existing RFCOMM session");
        }
        // Task eagerly removes the Session from the set of active sessions upon termination.
        let detached_session = self.sessions.get(&id).expect("just inserted");
        fasync::Task::spawn(async move {
            let _ = closed_fut.await;
            detached_session.detach();
        })
        .detach();
        Ok(())
    }
pub fn new_l2cap_connection ( & mut self , id : PeerId , l2cap : Channel ) -> Result < ( ) , Error > { if self . is_active_session ( & id ) { return Err ( format_err ! ( " " id ) ) ; } info ! ( " " id ) ; // Create a new RFCOMM Session with the provided `channel_opened_callback` which will be // called anytime an RFCOMM channel is created. Opened RFCOMM channels will be delivered // to the `clients` of the `RfcommServer`. let clients = self . clients . clone ( ) ; let channel_opened_callback = Box :: new ( move | server_channel , channel | { let peer_id = id ; let clients = clients . clone ( ) ; async move { clients . deliver_channel ( peer_id , server_channel , channel ) . await } . boxed ( ) } ) ; let mut session = Session :: create ( id , l2cap , channel_opened_callback ) ; let _ = session . iattach ( & self . inspect , inspect :: unique_name ( " " ) ) ; let closed_fut = session . finished ( ) ; if self . sessions . insert ( id , session ) . is_some ( ) { warn ! ( " " ) ; } // Task eagerly removes the Session from the set of active sessions upon termination. let detached_session = self . sessions . get ( & id ) . expect ( " " ) ; fasync :: Task :: spawn ( async move { let _ = closed_fut . await ; detached_session . detach ( ) ; } ) . detach ( ) ; Ok ( ( ) ) }
Handles an incoming L2CAP connection from the remote peer.
Handles an incoming L2CAP connection from the remote peer .
&mut self
id
PeerId
l2cap
Channel
&mut self
id
PeerId
l2cap
Channel