pub async fn next(&mut self) -> Result<ServerToClientEvent> {
        enum Event {
            FromServer(Result<ServerToClientEvent>),
            Tick,
        }

        loop {
            let Self {
                internal,
                ping_interval,
            } = self;

            let event = futures::select! {
                event = internal.get_event().fuse() => Event::FromServer(event),
                _ = ping_interval.tick().fuse() => Event::Tick,
            };

            match event {
                Event::FromServer(e) => match e? {
                    ServerToClientEvent::Pong { .. } => {}
                    e => return Ok(e),
                },
                Event::Tick => {
                    self.hb().await?;
                }
            }
        }
    }
/// Suitable for lower-level, manual handling of events.
Suitable for lower-level, manual handling of events.
Suitable for lower - level manual handling of events .
pub async fn next(&mut self) -> Result<ServerToClientEvent> {
        enum Event {
            FromServer(Result<ServerToClientEvent>),
            Tick,
        }
        loop {
            let Self {
                internal,
                ping_interval,
            } = self;
            let event = futures::select! {
                event = internal.get_event().fuse() => Event::FromServer(event),
                _ = ping_interval.tick().fuse() => Event::Tick,
            };
            match event {
                Event::FromServer(e) => match e? {
                    ServerToClientEvent::Pong { .. } => {}
                    e => return Ok(e),
                },
                Event::Tick => {
                    self.hb().await?;
                }
            }
        }
    }
pub async fn next ( & mut self ) -> Result < ServerToClientEvent > { enum Event { FromServer ( Result < ServerToClientEvent > ) , Tick , } loop { let Self { internal , ping_interval , } = self ; let event = futures :: select ! { event internal get_event ( ) fuse ( ) Event FromServer ( event ) ping_interval tick ( ) fuse ( ) Event Tick } ; match event { Event :: FromServer ( e ) => match e ? { ServerToClientEvent :: Pong { .. } => { } e => return Ok ( e ) , } , Event :: Tick => { self . hb ( ) . await ? ; } } } }
Suitable for lower-level, manual handling of events.
Suitable for lower - level manual handling of events .
&mut self
&mut self