[][src]Struct gdnative::api::MultiplayerAPI

pub struct MultiplayerAPI { /* fields omitted */ }

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

impl MultiplayerAPI[src]

pub fn new() -> Ref<MultiplayerAPI, 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) -> TypedArray<i32>[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: TypedArray<u8>,
    id: i64,
    mode: i64
) -> Result<(), GodotError>
[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]

type Target = Reference

The resulting type after dereferencing.

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

impl Instanciable for MultiplayerAPI[src]

impl SubClass<Object> for MultiplayerAPI[src]

impl SubClass<Reference> for MultiplayerAPI[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SubClass<T> for T where
    T: GodotObject
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.