Skip to main content

IMultiplayerPeerExtension

Trait IMultiplayerPeerExtension 

pub trait IMultiplayerPeerExtension: GodotClass<Base = MultiplayerPeerExtension> + You_forgot_the_attribute__godot_api {
Show 31 methods // Required methods fn get_available_packet_count(&self) -> i32; fn get_max_packet_size(&self) -> i32; fn get_packet_channel(&self) -> i32; fn get_packet_mode(&self) -> TransferMode; fn set_transfer_channel(&mut self, p_channel: i32); fn get_transfer_channel(&self) -> i32; fn set_transfer_mode(&mut self, p_mode: TransferMode); fn get_transfer_mode(&self) -> TransferMode; fn set_target_peer(&mut self, p_peer: i32); fn get_packet_peer(&self) -> i32; fn is_server(&self) -> bool; fn poll(&mut self); fn close(&mut self); fn disconnect_peer(&mut self, p_peer: i32, p_force: bool); fn get_unique_id(&self) -> i32; fn get_connection_status(&self) -> ConnectionStatus; // Provided methods fn init(base: Base<Self::Base>) -> Self { ... } fn on_notification(&mut self, what: ObjectNotification) { ... } fn on_get(&self, property: StringName) -> Option<Variant> { ... } fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... } fn on_validate_property(&self, property: &mut PropertyInfo) { ... } fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... } fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... } fn to_string(&self) -> GString { ... } unsafe fn get_packet_rawptr( &mut self, r_buffer: RawPtr<*mut RawPtr<*const u8>>, r_buffer_size: RawPtr<*mut i32>, ) -> Error { ... } unsafe fn put_packet_rawptr( &mut self, p_buffer: RawPtr<*const u8>, p_buffer_size: i32, ) -> Error { ... } fn get_packet_script(&mut self) -> PackedArray<u8> { ... } fn put_packet_script(&mut self, p_buffer: PackedArray<u8>) -> Error { ... } fn set_refuse_new_connections(&mut self, p_enable: bool) { ... } fn is_refusing_new_connections(&self) -> bool { ... } fn is_server_relay_supported(&self) -> bool { ... }
}
Expand description

§Interface trait for class MultiplayerPeerExtension.

Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.

Base interfaces: IMultiplayerPeer > IPacketPeer > IRefCounted > IObject.
(Strike-through means some intermediate Godot classes are marked final, and can thus not be inherited by GDExtension.)

See also Godot docs for MultiplayerPeerExtension methods.

Required Methods§

fn get_available_packet_count(&self) -> i32

Called when the available packet count is internally requested by the MultiplayerAPI.

fn get_max_packet_size(&self) -> i32

Called when the maximum allowed packet size (in bytes) is requested by the MultiplayerAPI.

fn get_packet_channel(&self) -> i32

Called to get the channel over which the next available packet was received. See get_packet_channel.

fn get_packet_mode(&self) -> TransferMode

Called to get the transfer mode the remote peer used to send the next available packet. See get_packet_mode.

fn set_transfer_channel(&mut self, p_channel: i32)

Called when the channel to use is set for this MultiplayerPeer (see [member MultiplayerPeer.transfer_channel]).

fn get_transfer_channel(&self) -> i32

Called when the transfer channel to use is read on this MultiplayerPeer (see [member MultiplayerPeer.transfer_channel]).

fn set_transfer_mode(&mut self, p_mode: TransferMode)

Called when the transfer mode is set on this MultiplayerPeer (see [member MultiplayerPeer.transfer_mode]).

fn get_transfer_mode(&self) -> TransferMode

Called when the transfer mode to use is read on this MultiplayerPeer (see [member MultiplayerPeer.transfer_mode]).

fn set_target_peer(&mut self, p_peer: i32)

Called when the target peer to use is set for this MultiplayerPeer (see set_target_peer).

fn get_packet_peer(&self) -> i32

Called when the ID of the MultiplayerPeer who sent the most recent packet is requested (see get_packet_peer).

fn is_server(&self) -> bool

Called when the “is server” status is requested on the MultiplayerAPI. See is_server.

fn poll(&mut self)

Called when the MultiplayerAPI is polled. See poll.

fn close(&mut self)

Called when the multiplayer peer should be immediately closed (see close).

fn disconnect_peer(&mut self, p_peer: i32, p_force: bool)

Called when the connected p_peer should be forcibly disconnected (see disconnect_peer).

fn get_unique_id(&self) -> i32

Called when the unique ID of this MultiplayerPeer is requested (see get_unique_id). The value must be between 1 and 2147483647.

fn get_connection_status(&self) -> ConnectionStatus

Called when the connection status is requested on the MultiplayerPeer (see get_connection_status).

Provided Methods§

fn init(base: Base<Self::Base>) -> Self

Godot constructor, accepting an injected base object.

base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded. This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.

If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.

fn on_notification(&mut self, what: ObjectNotification)

Called when the object receives a Godot notification.

The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_* constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists to represent integers out of known constants (mistakes or future additions).

This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the Object::notify method.

See also in Godot docs:

fn on_get(&self, property: StringName) -> Option<Variant>

Called whenever get() is called or Godot gets the value of a property.

Should return the given property’s value as Some(value), or None if the property should be handled normally.

See also in Godot docs:

fn on_set(&mut self, property: StringName, value: Variant) -> bool

Called whenever Godot set() is called or Godot sets the value of a property.

Should set property to the given value and return true, or return false to indicate the property should be handled normally.

See also in Godot docs:

fn on_validate_property(&self, property: &mut PropertyInfo)

Called whenever Godot retrieves value of property. Allows to customize existing properties. Every property info goes through this method, except properties added with on_get_property_list().

Exposed property here is a shared mutable reference obtained (and returned to) from Godot.

See also in the Godot docs:

fn on_get_property_list(&mut self) -> Vec<PropertyInfo>

Available on since_api=4.3 only.

Called whenever Godot get_property_list() is called, the returned vector here is appended to the existing list of properties.

This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.

See also in Godot docs:

fn on_property_get_revert(&self, property: StringName) -> Option<Variant>

Called by Godot to tell if a property has a custom revert or not.

Return None for no custom revert, and return Some(value) to specify the custom revert.

This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this function will usually be called twice by Godot to find the revert.

Note that this should be a pure function. That is, it should always return the same value for a property as long as self remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.

fn to_string(&self) -> GString

String representation of the Godot instance.

Override this method to define how the instance is represented as a string. Used by impl Display for Gd<T>, as well as str() and print() in GDScript.

unsafe fn get_packet_rawptr( &mut self, r_buffer: RawPtr<*mut RawPtr<*const u8>>, r_buffer_size: RawPtr<*mut i32>, ) -> Error

§Godot docs

Called when a packet needs to be received by the MultiplayerAPI, with r_buffer_size being the size of the binary r_buffer in bytes.

§Safety

This method has automatically been marked unsafe because it accepts raw pointers as parameters. If Godot does not document any safety requirements, make sure you understand the underlying semantics.

unsafe fn put_packet_rawptr( &mut self, p_buffer: RawPtr<*const u8>, p_buffer_size: i32, ) -> Error

§Godot docs

Called when a packet needs to be sent by the MultiplayerAPI, with p_buffer_size being the size of the binary p_buffer in bytes.

§Safety

This method has automatically been marked unsafe because it accepts raw pointers as parameters. If Godot does not document any safety requirements, make sure you understand the underlying semantics.

fn get_packet_script(&mut self) -> PackedArray<u8>

Called when a packet needs to be received by the MultiplayerAPI, if get_packet_rawptr isn’t implemented. Use this when extending this class via GDScript.

fn put_packet_script(&mut self, p_buffer: PackedArray<u8>) -> Error

Called when a packet needs to be sent by the MultiplayerAPI, if put_packet_rawptr isn’t implemented. Use this when extending this class via GDScript.

fn set_refuse_new_connections(&mut self, p_enable: bool)

Called when the “refuse new connections” status is set on this MultiplayerPeer (see [member MultiplayerPeer.refuse_new_connections]).

fn is_refusing_new_connections(&self) -> bool

Called when the “refuse new connections” status is requested on this MultiplayerPeer (see [member MultiplayerPeer.refuse_new_connections]).

fn is_server_relay_supported(&self) -> bool

Called to check if the server can act as a relay in the current configuration. See is_server_relay_supported.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§