pub fn poll_send(&mut self, cx: &mut Context<'_>, mut buf: &[u8]) -> Poll<KcpResult<usize>> {
        if self.closed {
            return Ok(0).into();
        }

        // If:
        //     1. Have sent the first packet (asking for conv)
        //     2. Too many pending packets
        if self.sent_first
            && (self.kcp.wait_snd() >= self.kcp.snd_wnd() as usize || self.kcp.waiting_conv())
        {
            trace!(
                "[SEND] waitsnd={} sndwnd={} excceeded or waiting conv={}",
                self.kcp.wait_snd(),
                self.kcp.snd_wnd(),
                self.kcp.waiting_conv()
            );
            self.pending_sender = Some(cx.waker().clone());
            return Poll::Pending;
        }

        if !self.sent_first && self.kcp.waiting_conv() && buf.len() > self.kcp.mss() as usize {
            buf = &buf[..self.kcp.mss() as usize];
        }

        let n = self.kcp.send(buf)?;
        self.sent_first = true;
        self.last_update = Instant::now();

        if self.flush_write {
            self.kcp.flush()?;
        }

        Ok(n).into()
    }
/// Call if you want to send some data
Call if you want to send some data
Call if you want to send some data
pub fn poll_send(&mut self, cx: &mut Context<'_>, mut buf: &[u8]) -> Poll<KcpResult<usize>> {
        if self.closed {
            return Ok(0).into();
        }
        // If:
        //     1. Have sent the first packet (asking for conv)
        //     2. Too many pending packets
        if self.sent_first
            && (self.kcp.wait_snd() >= self.kcp.snd_wnd() as usize || self.kcp.waiting_conv())
        {
            trace!(
                "[SEND] waitsnd={} sndwnd={} excceeded or waiting conv={}",
                self.kcp.wait_snd(),
                self.kcp.snd_wnd(),
                self.kcp.waiting_conv()
            );
            self.pending_sender = Some(cx.waker().clone());
            return Poll::Pending;
        }
        if !self.sent_first && self.kcp.waiting_conv() && buf.len() > self.kcp.mss() as usize {
            buf = &buf[..self.kcp.mss() as usize];
        }
        let n = self.kcp.send(buf)?;
        self.sent_first = true;
        self.last_update = Instant::now();
        if self.flush_write {
            self.kcp.flush()?;
        }
        Ok(n).into()
    }
pub fn poll_send ( & mut self , cx : & mut Context < ' _ > , mut buf : & [ u8 ] ) -> Poll < KcpResult < usize > > { if self . closed { return Ok ( 0 ) . into ( ) ; } // If: //     1. Have sent the first packet (asking for conv) //     2. Too many pending packets if self . sent_first && ( self . kcp . wait_snd ( ) >= self . kcp . snd_wnd ( ) as usize || self . kcp . waiting_conv ( ) ) { trace ! ( " " self kcp wait_snd ( ) self kcp snd_wnd ( ) self kcp waiting_conv ( ) ) ; self . pending_sender = Some ( cx . waker ( ) . clone ( ) ) ; return Poll :: Pending ; } if ! self . sent_first && self . kcp . waiting_conv ( ) && buf . len ( ) > self . kcp . mss ( ) as usize { buf = & buf [ .. self . kcp . mss ( ) as usize ] ; } let n = self . kcp . send ( buf ) ? ; self . sent_first = true ; self . last_update = Instant :: now ( ) ; if self . flush_write { self . kcp . flush ( ) ? ; } Ok ( n ) . into ( ) }
Call if you want to send some data
Call if you want to send some data
&mut self
cx
&mut Context<'_>
buf
&[u8]
&mut self
cx
&mut Context<'_>
buf
&[u8]