pub struct GodotGGRSP2PSession { /* private fields */ }
Expand description

A Godot implementation of P2PSession

Implementations

Creates a P2PSession, call this when you want to start setting up a P2P Session takes the local port, total number of players and max prediction frames as parameters.

Notes
  • Max prediction frames is the maximum number of frames GGRS will roll back. Every gamestate older than this is guaranteed to be correct if the players did not desync.
  • This value used to default to 8 frames, but this has been made adjustable with GGRS 0.7.0
👎 Deprecated since 0.5.0:

please use create_new_session() instead

Deprecated method to create a P2PSession. Use Self::create_new_session() instead.

Adds a local player to the session and return the handle.

Errors

Adds a remote player to the session and returns the handle.

Example

The following example shows how to format an address string, starting with the IP and ending with the port.

p2p.add_remote_player("127.0.0.1:7070")
Errors

Adds a spectator to the session and returns the handle

Errors

Starts the P2PSession

Errors

Returns true if connection has been established with remote players and is ready to start taking inputs via Self::advance_frame()

Returns the current sate of the session as a String. Take a look at SessionState for all possible states.

This function will advance the frame using the inputs given as a parameter (currently an int in Godot) Before using this function you have to set the callback node and make sure it has the following callback functions implemented

Errors

Sets P2PSession::set_fps()

Errors

Sets the callback node that will be called when using Self::advance_frame()

Calls P2PSession::poll_remote_clients()

Errors

Prints out network stats of specified handle

Errors

Will return network stats of specified handle as a tuple, which will be converted to an Array inside godot.

Errors

Sets P2PSession::set_frame_delay() of specified handle.

Errors

Sets P2PSession::set_disconnect_timeout() converting the u64 to secconds.

Errors

Sets P2PSession::set_disconnect_notify_delay() converting the u64 to secconds.

Errors

Sets P2PSession::set_sparse_saving().

Errors

Disconnects specified player handle.

Errors

Returns an Array of events which contain usefull information, while you don’t have to implement everything, the one thing you should implement is the WaitRecommendation. For details regarding the events please take a loot at GGRSEvent.

Example
var events = ggrs.get_events()
for item in events:
    match item[0]:
        "WaitRecommendation":
            frames_to_skip += item[1]
        "NetworkInterrupted":
            var handle = item[1][0]
            var disconnect_timeout = item[1][1]
        "NetworkResumed":
            var handle = item[1]
        "Disconnected":
            var handle = item[1]
        "Synchronized":
            var handle = item[1]
        "Synchronizing":
            var handle = item[1][0]
            var total = item[1][1]
            var count = item[1][2]
Errors

Calls and returns P2PSession::frames_ahead(). Will return a 0 if no session was made.

Errors

Calls and returns P2PSession::max_prediction(). Will return a 0 if no session was made.

Errors

Calls and returns P2PSession::current_frame(). Will return a 0 if no session was made.

Errors

Calls and returns P2PSession::confirmed_frame(). Will return a 0 if no session was made.

Errors

Trait Implementations

Base type of the class. Read more

User-data wrapper type of the class. Read more

The name of the class. Read more

Function that creates a value of Self, used for the script-instance. The default implementation simply panics. Read more

Register any exported properties to Godot.

Convenience method to create an Instance<Self, Unique>. This is a new Self::Base with the script attached. Read more

Convenience method to emplace self into an Instance<Self, Unique>. This is a new Self::Base with the script attached. Read more

Function that registers all exposed methods to Godot.

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.