Struct ggrs::SpectatorSession

source ·
pub struct SpectatorSession<T>where
    T: Config,{ /* private fields */ }
Expand description

SpectatorSession provides all functionality to connect to a remote host in a peer-to-peer fashion. The host will broadcast all confirmed inputs to this session. This session can be used to spectate a session without contributing to the game input.

Implementations§

source§

impl<T: Config> SpectatorSession<T>

source

pub fn current_state(&self) -> SessionState

Returns the current SessionState of a session.

source

pub fn frames_behind_host(&self) -> usize

Returns the number of frames behind the host

source

pub fn network_stats(&self) -> Result<NetworkStats, GGRSError>

Used to fetch some statistics about the quality of the network connection.

Errors
  • Returns NotSynchronized if the session is not connected to other clients yet.
source

pub fn events(&mut self) -> Drain<'_, GGRSEvent<T>>

Returns all events that happened since last queried for events. If the number of stored events exceeds MAX_EVENT_QUEUE_SIZE, the oldest events will be discarded.

source

pub fn advance_frame(&mut self) -> Result<Vec<GGRSRequest<T>>, GGRSError>

You should call this to notify GGRS that you are ready to advance your gamestate by a single frame. Returns an order-sensitive Vec<GGRSRequest>. You should fulfill all requests in the exact order they are provided. Failure to do so will cause panics later.

Errors
  • Returns NotSynchronized if the session is not yet ready to accept input. In this case, you either need to start the session or wait for synchronization between clients.
source

pub fn poll_remote_clients(&mut self)

Receive UDP packages, distribute them to corresponding UDP endpoints, handle all occurring events and send all outgoing UDP packages. Should be called periodically by your application to give GGRS a chance to do internal work like packet transmissions.

source

pub fn num_players(&self) -> usize

Returns the number of players this session was constructed with.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for SpectatorSession<T>

§

impl<T> !Send for SpectatorSession<T>

§

impl<T> !Sync for SpectatorSession<T>

§

impl<T> Unpin for SpectatorSession<T>where <T as Config>::Address: Unpin, <T as Config>::Input: Unpin,

§

impl<T> !UnwindSafe for SpectatorSession<T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V