pub struct GodotGGRSP2PSpectatorSession { /* private fields */ }
Expand description
A Godot implementation of P2PSpectatorSession
Implementations
sourceimpl GodotGGRSP2PSpectatorSession
impl GodotGGRSP2PSpectatorSession
sourcepub fn create_new_session(
&mut self,
_owner: &Node,
local_port: u16,
num_players: u32,
host_addr: String
)
pub fn create_new_session(
&mut self,
_owner: &Node,
local_port: u16,
num_players: u32,
host_addr: String
)
Creates a P2PSpectatorSession, call this when you want to start setting up a P2PSpectatorSession
.
Takes the local port and total number of players and the host address as parameters.
sourcepub fn create_session(
&mut self,
_owner: &Node,
local_port: u16,
num_players: u32,
host_addr: String
)
👎 Deprecated since 0.5.0: please use create_new_session()
instead
pub fn create_session(
&mut self,
_owner: &Node,
local_port: u16,
num_players: u32,
host_addr: String
)
please use create_new_session()
instead
Deprecated method to create a P2PSpectatorSession. Use Self::create_new_session() instead.
sourcepub fn is_running(&mut self, _owner: &Node) -> bool
pub fn is_running(&mut self, _owner: &Node) -> bool
Returns true if connection has been established with remote players and is ready to start advancing frames via Self::advance_frame()
sourcepub fn get_current_state(&mut self, _owner: &Node) -> String
pub fn get_current_state(&mut self, _owner: &Node) -> String
Returns the current sate of the session as a String. See SessionState for all possible states.
sourcepub fn start_session(&mut self, _owner: &Node)
pub fn start_session(&mut self, _owner: &Node)
Starts the P2PSpectatorSession
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn set_callback_node(&mut self, _owner: &Node, callback: Ref<Node>)
pub fn set_callback_node(&mut self, _owner: &Node, callback: Ref<Node>)
Sets the callback node that will be called when using Self::advance_frame()
sourcepub fn advance_frame(&mut self, _owner: &Node)
pub fn advance_frame(&mut self, _owner: &Node)
This function will advance the frame using the inputs received from the host_session. Before using this function you have to set the callback node and make sure it has the following callback functions implemented
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
- Will print a ERR_MESSAGE_NO_CALLBACK_NODE error if a callback node has not been set
sourcepub fn get_frames_behind_host(&mut self, _owner: &Node) -> u32
pub fn get_frames_behind_host(&mut self, _owner: &Node) -> u32
Returns P2PSpectatorSession::frames_behind_host()
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn set_catchup_speed(&mut self, _owner: &Node, desired_catchup_speed: u32)
pub fn set_catchup_speed(&mut self, _owner: &Node, desired_catchup_speed: u32)
Sets P2PSpectatorSession::set_catchup_speed()
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn set_max_frames_behind(&mut self, _owner: &Node, desired_value: u32)
pub fn set_max_frames_behind(&mut self, _owner: &Node, desired_value: u32)
Sets P2PSpectatorSession::set_max_frames_behind()
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn poll_remote_clients(&mut self, _owner: &Node)
pub fn poll_remote_clients(&mut self, _owner: &Node)
Calls P2PSpectatorSession::poll_remote_clients()
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn set_fps(&mut self, _owner: &Node, fps: u32)
pub fn set_fps(&mut self, _owner: &Node, fps: u32)
Sets P2PSpectatorSession::set_fps()
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn print_network_stats(&mut self, _owner: &Node)
pub fn print_network_stats(&mut self, _owner: &Node)
Prints out network stats of host address
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn get_network_stats(
&mut self,
_owner: &Node
) -> (usize, u64, usize, i32, i32)
pub fn get_network_stats(
&mut self,
_owner: &Node
) -> (usize, u64, usize, i32, i32)
Will return network stats of host address as a tuple
, which will be converted to an Array
inside godot.
Errors
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
sourcepub fn get_events(&mut self, _owner: &Node) -> Vec<(&str, Variant)>
pub fn get_events(&mut self, _owner: &Node) -> Vec<(&str, Variant)>
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
- Will print a ERR_MESSAGE_NO_SESSION_MADE error if a session has not been made
Trait Implementations
sourceimpl NativeClass for GodotGGRSP2PSpectatorSession
impl NativeClass for GodotGGRSP2PSpectatorSession
type UserData = DefaultUserData<GodotGGRSP2PSpectatorSession>
type UserData = DefaultUserData<GodotGGRSP2PSpectatorSession>
User-data wrapper type of the class. Read more
sourcefn class_name() -> &'static str
fn class_name() -> &'static str
The name of the class. Read more
sourcefn init(owner: TRef<'_, Self::Base>) -> Self
fn init(owner: TRef<'_, Self::Base>) -> Self
Function that creates a value of Self
, used for the script-instance. The default
implementation simply panics. Read more
sourcefn register_properties(builder: &ClassBuilder<Self>)
fn register_properties(builder: &ClassBuilder<Self>)
Register any exported properties to Godot.
fn new_instance() -> Instance<Self, Unique> where
Self::Base: Instanciable,
fn new_instance() -> Instance<Self, Unique> where
Self::Base: Instanciable,
Convenience method to create an Instance<Self, Unique>
. This is a new Self::Base
with the script attached. Read more
sourceimpl NativeClassMethods for GodotGGRSP2PSpectatorSession
impl NativeClassMethods for GodotGGRSP2PSpectatorSession
Auto Trait Implementations
impl !RefUnwindSafe for GodotGGRSP2PSpectatorSession
impl Send for GodotGGRSP2PSpectatorSession
impl Sync for GodotGGRSP2PSpectatorSession
impl Unpin for GodotGGRSP2PSpectatorSession
impl !UnwindSafe for GodotGGRSP2PSpectatorSession
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more