[−][src]Struct gdnative_bindings::multiplayer_api::MultiplayerAPI
core class MultiplayerAPI
inherits Reference
(reference counted).
Official documentation
See the documentation of this class in the Godot engine's official documentation.
Memory management
The lifetime of this object is automatically managed through reference counting.
Class hierarchy
MultiplayerAPI inherits methods from:
Safety
All types in the Godot API have "interior mutability" in Rust parlance.
To enforce that the official thread-safety guidelines are
followed, the typestate pattern is used in the Ref
and TRef
smart pointers,
and the Instance
API. The typestate Access
in these types tracks whether the
access is unique, shared, or exclusive to the current thread. For more information,
see the type-level documentation on Ref
.
Implementations
impl MultiplayerAPI
[src]
Constants
pub const RPC_MODE_DISABLED: i64
[src]
pub const RPC_MODE_MASTER: i64
[src]
pub const RPC_MODE_MASTERSYNC: i64
[src]
pub const RPC_MODE_PUPPET: i64
[src]
pub const RPC_MODE_PUPPETSYNC: i64
[src]
pub const RPC_MODE_REMOTE: i64
[src]
pub const RPC_MODE_REMOTESYNC: i64
[src]
pub const RPC_MODE_SLAVE: i64
[src]
pub const RPC_MODE_SYNC: i64
[src]
impl MultiplayerAPI
[src]
pub fn new() -> Ref<Self, Unique>
[src]
Creates a new instance of this object.
This is a reference-counted type. The returned object is automatically managed
by Ref
.
pub fn clear(&self)
[src]
Clears the current MultiplayerAPI network state (you shouldn't call this unless you know what you are doing).
pub fn get_network_connected_peers(&self) -> Int32Array
[src]
Returns the peer IDs of all connected peers of this MultiplayerAPI's [member network_peer].
pub fn network_peer(&self) -> Option<Ref<NetworkedMultiplayerPeer, Shared>>
[src]
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the MultiplayerAPI will become a network server (check with [method is_network_server]) and will set root node's network mode to master, or it will become a regular peer with root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to MultiplayerAPI's signals.
pub fn get_network_unique_id(&self) -> i64
[src]
Returns the unique peer ID of this MultiplayerAPI's [member network_peer].
pub fn get_rpc_sender_id(&self) -> i64
[src]
Returns the sender's peer ID for the RPC currently being executed.
[b]Note:[/b] If not inside an RPC this method will return 0.
pub fn has_network_peer(&self) -> bool
[src]
Returns [code]true[/code] if there is a [member network_peer] set.
pub fn is_network_server(&self) -> bool
[src]
Returns [code]true[/code] if this MultiplayerAPI's [member network_peer] is in server mode (listening for connections).
pub fn is_object_decoding_allowed(&self) -> bool
[src]
If [code]true[/code] (or if the [member network_peer] has [member PacketPeer.allow_object_decoding] set to [code]true[/code]), the MultiplayerAPI will allow encoding and decoding of object during RPCs/RSETs.
[b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
pub fn is_refusing_new_network_connections(&self) -> bool
[src]
If [code]true[/code], the MultiplayerAPI's [member network_peer] refuses new incoming connections.
pub fn poll(&self)
[src]
Method used for polling the MultiplayerAPI. You only need to worry about this if you are using [member Node.custom_multiplayer] override or you set [member SceneTree.multiplayer_poll] to [code]false[/code]. By default, [SceneTree] will poll its MultiplayerAPI for you.
[b]Note:[/b] This method results in RPCs and RSETs being called, so they will be executed in the same context of this function (e.g. [code]_process[/code], [code]physics[/code], [Thread]).
pub fn send_bytes(&self, bytes: ByteArray, id: i64, mode: i64) -> GodotResult
[src]
Sends the given raw [code]bytes[/code] to a specific peer identified by [code]id[/code] (see [method NetworkedMultiplayerPeer.set_target_peer]). Default ID is [code]0[/code], i.e. broadcast to all peers.
Default Arguments
id
-0
mode
-2
pub fn set_allow_object_decoding(&self, enable: bool)
[src]
If [code]true[/code] (or if the [member network_peer] has [member PacketPeer.allow_object_decoding] set to [code]true[/code]), the MultiplayerAPI will allow encoding and decoding of object during RPCs/RSETs.
[b]Warning:[/b] Deserialized objects can contain code which gets executed. Do not use this option if the serialized object comes from untrusted sources to avoid potential security threats such as remote code execution.
pub fn set_network_peer(&self, peer: impl AsArg<NetworkedMultiplayerPeer>)
[src]
The peer object to handle the RPC system (effectively enabling networking when set). Depending on the peer itself, the MultiplayerAPI will become a network server (check with [method is_network_server]) and will set root node's network mode to master, or it will become a regular peer with root node set to puppet. All child nodes are set to inherit the network mode by default. Handling of networking-related events (connection, disconnection, new clients) is done by connecting to MultiplayerAPI's signals.
pub fn set_refuse_new_network_connections(&self, refuse: bool)
[src]
If [code]true[/code], the MultiplayerAPI's [member network_peer] refuses new incoming connections.
pub fn set_root_node(&self, node: impl AsArg<Node>)
[src]
Sets the base root node to use for RPCs. Instead of an absolute path, a relative path will be used to find the node upon which the RPC should be executed.
This effectively allows to have different branches of the scene tree to be managed by different MultiplayerAPI, allowing for example to run both client and server in the same scene.
Methods from Deref<Target = Reference>
pub fn init_ref(&self) -> bool
[src]
Initializes the internal reference counter. Use this only if you really know what you are doing.
Returns whether the initialization was successful.
Trait Implementations
impl Debug for MultiplayerAPI
[src]
impl Deref for MultiplayerAPI
[src]
impl DerefMut for MultiplayerAPI
[src]
impl GodotObject for MultiplayerAPI
[src]
type RefKind = RefCounted
The memory management kind of this type. This modifies the behavior of the
Ref
smart pointer. See its type-level documentation for more
information. Read more
fn class_name() -> &'static str
[src]
fn null() -> Null<Self>
[src]
fn new() -> Ref<Self, Unique> where
Self: Instanciable,
[src]
Self: Instanciable,
fn cast<T>(&self) -> Option<&T> where
T: GodotObject + SubClass<Self>,
[src]
T: GodotObject + SubClass<Self>,
fn upcast<T>(&self) -> &T where
Self: SubClass<T>,
T: GodotObject,
[src]
Self: SubClass<T>,
T: GodotObject,
unsafe fn assume_shared(&self) -> Ref<Self, Shared>
[src]
unsafe fn assume_thread_local(&self) -> Ref<Self, ThreadLocal> where
Self: GodotObject<RefKind = RefCounted>,
[src]
Self: GodotObject<RefKind = RefCounted>,
unsafe fn assume_unique(&self) -> Ref<Self, Unique>
[src]
impl Instanciable for MultiplayerAPI
[src]
impl Sealed for MultiplayerAPI
[src]
impl SubClass<Object> for MultiplayerAPI
[src]
impl SubClass<Reference> for MultiplayerAPI
[src]
Auto Trait Implementations
impl RefUnwindSafe for MultiplayerAPI
impl !Send for MultiplayerAPI
impl !Sync for MultiplayerAPI
impl Unpin for MultiplayerAPI
impl UnwindSafe for MultiplayerAPI
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> SubClass<T> for T where
T: GodotObject,
[src]
T: GodotObject,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,