pub async fn add_player<'a, P, J, K>(
        &mut self,
        player: K,
        scope: &'a Scope<'a>,
    ) -> Result<Unpacked<'a, J>, ClientError<C::Error>>
    where
        P: Schema,
        J: Schema,
        K: Pack<P>,
    {
        self.channel
            .send_reliable::<ClientMessage<P>, _>(ClientMessageAddPlayerPack { player }, scope)
            .await?;

        loop {
            match self.channel.recv::<ServerMessage<J>>(scope) {
                Ok(Some(ServerMessageUnpacked::PlayerJoined { info })) => return Ok(info),
                Ok(Some(ServerMessageUnpacked::Connected { .. })) => {
                    return Err(ClientError::UnexpectedMessage)
                }
                Ok(Some(ServerMessageUnpacked::Updates { .. })) => {}
                Ok(None) => {
                    self.channel.recv_ready().await?;
                }
                Err(err) => return Err(err.into()),
            }
        }
    }
/// Adds new player to the session.
Adds new player to the session.
Adds new player to the session .
pub async fn add_player<'a, P, J, K>(
        &mut self,
        player: K,
        scope: &'a Scope<'a>,
    ) -> Result<Unpacked<'a, J>, ClientError<C::Error>>
    where
        P: Schema,
        J: Schema,
        K: Pack<P>,
    {
        self.channel
            .send_reliable::<ClientMessage<P>, _>(ClientMessageAddPlayerPack { player }, scope)
            .await?;
        loop {
            match self.channel.recv::<ServerMessage<J>>(scope) {
                Ok(Some(ServerMessageUnpacked::PlayerJoined { info })) => return Ok(info),
                Ok(Some(ServerMessageUnpacked::Connected { .. })) => {
                    return Err(ClientError::UnexpectedMessage)
                }
                Ok(Some(ServerMessageUnpacked::Updates { .. })) => {}
                Ok(None) => {
                    self.channel.recv_ready().await?;
                }
                Err(err) => return Err(err.into()),
            }
        }
    }
pub async fn add_player < ' a , P , J , K > ( & mut self , player : K , scope : & ' a Scope < ' a > , ) -> Result < Unpacked < ' a , J > , ClientError < C :: Error > > where P : Schema , J : Schema , K : Pack < P > , { self . channel . send_reliable :: < ClientMessage < P > , _ > ( ClientMessageAddPlayerPack { player } , scope ) . await ? ; loop { match self . channel . recv :: < ServerMessage < J > > ( scope ) { Ok ( Some ( ServerMessageUnpacked :: PlayerJoined { info } ) ) => return Ok ( info ) , Ok ( Some ( ServerMessageUnpacked :: Connected { .. } ) ) => { return Err ( ClientError :: UnexpectedMessage ) } Ok ( Some ( ServerMessageUnpacked :: Updates { .. } ) ) => { } Ok ( None ) => { self . channel . recv_ready ( ) . await ? ; } Err ( err ) => return Err ( err . into ( ) ) , } } }
Adds new player to the session.
Adds new player to the session .
&mut self
player
K
scope
&'a Scope<'a>