Struct ggrs::P2PSession[][src]

pub struct P2PSession { /* fields omitted */ }
Expand description

A P2PSession provides a UDP protocol to connect to remote clients in a peer-to-peer fashion.

Implementations

Must be called for each player in the session (e.g. in a 3 player session, must be called 3 times) before starting the session. Returns the player handle used by GGRS to represent that player internally. The player handle will be the same you provided for players, but player_handle + 1000 for spectators. You will need the player handle to add input, change parameters or disconnect the player or spectator.

Errors

  • Returns InvalidHandle when the provided player handle is too big for the number of players
  • Returns InvalidRequest if a player with that handle has been added before
  • Returns InvalidRequest if the session has already been started
  • Returns InvalidRequest when adding more than one local player

After you are done defining and adding all players, you should start the session. Then, the synchronization process will begin.

Errors

  • Returns InvalidRequest if the session has already been started or if insufficient players have been registered.

Disconnects a remote player from a game.

Errors

  • Returns InvalidRequest if you try to disconnect a player who has already been disconnected or if you try to disconnect 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 InvalidHandle if the provided player handle is higher than the number of players.
  • 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 UDP packets, distribute them to corresponding endpoints, handle all occurring events and send all outgoing UDP packets.

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

Errors

  • Returns InvalidHandle if the provided player handle does not refer to an existing remote player.
  • Returns NotSynchronized if the session is not connected to other clients yet.

Change the amount of frames GGRS will delay the inputs for a player. You should only set the frame delay for local players.

Errors

  • Returns InvalidHandle if the provided player handle is invalid.
  • Returns InvalidRequest if the provided player handle does not refer to a local player.

Sets the disconnect timeout. The session will automatically disconnect from a remote peer if it has not received a packet in the timeout window.

Sets the time before the first notification will be sent in case of a prolonged period of no received packages.

Sets the FPS this session is used with. This influences estimations for frame synchronization between sessions.

Sets the sparse saving mode. With sparse saving turned on, only the minimum confirmed frame (for which all inputs from all players are confirmed correct) will be saved. This leads to much less save requests at the cost of potentially longer rollbacks and thus more advance frame requests. Recommended, if saving your gamestate takes much more time than advancing the game state.

Returns the handle of the local player, if the player is already added

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 this session was constructed with.

Returns the input size this session was constructed with.

Trait Implementations

Formats the value using the given formatter. Read more

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

Performs the conversion.

Performs the conversion.

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.