pub struct P2PSession<T> where
    T: Config
{ /* private fields */ }
Expand description

A P2PSession provides all functionality to connect to remote clients in a peer-to-peer fashion, exchange inputs and handle the gamestate by saving, loading and advancing.

Implementations

Registers local input for a player for the current frame. This should be successfully called for every local player before calling advance_frame(). If this is called multiple times for the same player before advancing the frame, older given inputs will be overwritten.

Errors
  • Returns InvalidRequest when the given handle does not refer to a local player.

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 InvalidRequest if the provided player handle refers to a remote player.
  • 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.

Should be called periodically by your application to give GGRS a chance to do internal work. GGRS will receive packets, distribute them to corresponding endpoints, handle all occurring events and send all outgoing packets.

Disconnects a remote player and all other remote players with the same address from the session.

Errors
  • Returns InvalidRequest if you try to disconnect a local player or the provided handle is invalid.

Returns a NetworkStats struct that gives information about the quality of the network connection.

Errors
  • Returns InvalidRequest if the handle not referring to a remote player or spectator.
  • Returns NotSynchronized if the session is not connected to other clients yet.

Returns the highest confirmed frame. We have received all input for this frame and it is thus correct.

Returns the current frame of a session.

Returns the maximum prediction window of a session.

Returns the current SessionState of a session.

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.

Returns the number of players added to this session

Return the number of spectators currently registered

Returns the handles of local players that have been added

Returns the handles of remote players that have been added

Returns the handles of spectators that have been added

Returns all handles associated to a certain address

Returns the number of frames this session is estimated to be ahead of other sessions

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.