Struct backroll::P2PSession[][src]

pub struct P2PSession<T> where
    T: BackrollConfig
{ /* fields omitted */ }

Implementations

impl<T: BackrollConfig> P2PSession<T>[src]

pub fn build() -> P2PSessionBuilder<T>[src]

pub fn player_count(&self) -> usize[src]

Gets the number of players in the current session. This includes users that are already disconnected.

pub fn in_rollback(&self) -> bool[src]

Checks if the session currently in the middle of a rollback.

pub fn current_frame(&self) -> i32[src]

Gets the current frame of the game.

pub fn local_players(&self) -> impl Iterator<Item = BackrollPlayerHandle> + '_[src]

pub fn remote_players(&self) -> impl Iterator<Item = BackrollPlayerHandle> + '_[src]

pub fn is_synchronized(&self) -> bool[src]

Checks if all remote players are synchronized. If all players are local, this will always return true.

pub fn add_local_input(
    &mut self,
    player: BackrollPlayerHandle,
    input: T::Input
) -> BackrollResult<()>
[src]

Adds a local input for the current frame. This will register the input in the local input queues, as well as queue the input to be sent to all remote players. If called multiple times for the same player without advancing the session with advance_frame, the previously queued input for the frame will be overwritten.

For a corrrect simulation, this must be called on all local players every frame before calling advance_frame.

Errors

Returns BackrollError::InRollback if the session is currently in the middle of a rollback.

Returns BackrollError::NotSynchronized if the all of the remote peers have not yet synchornized.

Returns BackrollError::InvalidPlayer if the provided player handle does not point a vali player.

pub fn advance_frame(&mut self, callbacks: &mut impl SessionCallbacks<T>)[src]

Advances the game simulation by a single frame. This will call SessionCallbacks::advance_frame then check if the simulation is consistent with the inputs sent by remote players. If not, a rollback will be triggered, and the game will be saved and resimulated from the point of rollback.

For a corrrect simulation, add_local_input must be called on all local players every frame before calling this.

pub fn disconnect_player(
    &mut self,
    callbacks: &mut impl SessionCallbacks<T>,
    player: BackrollPlayerHandle
) -> BackrollResult<()>
[src]

Disconnects a player from the game.

If called on a local player, this will disconnect the client from all remote peers.

If called on a remote player, this will disconnect the connection with only that player.

Errors

Returns BackrollError::InvalidPlayer if the provided player handle does not point a vali player.

Returns BackrollError::PlayerDisconnected if the provided player is already disconnected.

pub fn get_network_stats(
    &self,
    player: BackrollPlayerHandle
) -> BackrollResult<NetworkStats>
[src]

Gets network statistics with a remote player.

Errors

Returns BackrollError::InvalidPlayer if the provided player handle does not point a vali player.

pub fn set_frame_delay(
    &mut self,
    player: BackrollPlayerHandle,
    delay: i32
) -> BackrollResult<()>
[src]

Sets the frame delay for a given player.

Errors

Returns BackrollError::InvalidPlayer if the provided player handle does not point a vali player.

Auto Trait Implementations

impl<T> !RefUnwindSafe for P2PSession<T>

impl<T> Send for P2PSession<T>

impl<T> Sync for P2PSession<T>

impl<T> Unpin for P2PSession<T> where
    <T as BackrollConfig>::Input: Unpin

impl<T> !UnwindSafe for P2PSession<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V