SceneMultiplayer

package
v0.0.0-...-0d6c339 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

This class is the default implementation of graphics.gd/classdb/MultiplayerAPI, used to provide multiplayer functionalities in Godot Engine.

This implementation supports RPCs via graphics.gd/classdb/Node.Instance.Rpc and graphics.gd/classdb/Node.Instance.RpcId and requires graphics.gd/classdb/MultiplayerAPI.Instance.Rpc to be passed a graphics.gd/classdb/Node (it will fail for other object types).

This implementation additionally provide graphics.gd/classdb/SceneTree replication via the graphics.gd/classdb/MultiplayerSpawner and graphics.gd/classdb/MultiplayerSynchronizer nodes, and the graphics.gd/classdb/SceneReplicationConfig resource.

Note: The high-level multiplayer API protocol is an implementation detail and isn't meant to be used by non-Godot servers. It may change without notice.

Note: When exporting to Android, make sure to enable the INTERNET permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsSceneMultiplayer() Instance
}

type Expanded

type Expanded [1]gdclass.SceneMultiplayer

func (Expanded) SendBytes

func (self Expanded) SendBytes(bytes []byte, id int, mode MultiplayerPeer.TransferMode, channel int) error

Sends the given raw 'bytes' to a specific peer identified by 'id' (see graphics.gd/classdb/MultiplayerPeer.Instance.SetTargetPeer). Default ID is 0, i.e. broadcast to all peers.

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsMultiplayerAPI

func (self *Extension[T]) AsMultiplayerAPI() MultiplayerAPI.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsSceneMultiplayer

func (self *Extension[T]) AsSceneMultiplayer() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.SceneMultiplayer

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AllowObjectDecoding

func (self Instance) AllowObjectDecoding() bool

func (Instance) AsMultiplayerAPI

func (self Instance) AsMultiplayerAPI() MultiplayerAPI.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsSceneMultiplayer

func (self Instance) AsSceneMultiplayer() Instance

func (Instance) AuthCallback

func (self Instance) AuthCallback() Callable.Function

func (Instance) AuthTimeout

func (self Instance) AuthTimeout() Float.X

func (Instance) Clear

func (self Instance) Clear()

Clears the current SceneMultiplayer network state (you shouldn't call this unless you know what you are doing).

func (Instance) CompleteAuth

func (self Instance) CompleteAuth(id int) error

Mark the authentication step as completed for the remote peer identified by 'id'. The [Instance.OnMultiplayerapi.PeerConnected] signal will be emitted for this peer once the remote side also completes the authentication. No further authentication messages are expected to be received from this peer.

If a peer disconnects before completing authentication, either due to a network issue, the Instance.AuthTimeout expiring, or manually calling Instance.DisconnectPeer, the Instance.OnPeerAuthenticationFailed signal will be emitted instead of [Instance.OnMultiplayerapi.PeerDisconnected].

func (Instance) DisconnectPeer

func (self Instance) DisconnectPeer(id int)

Disconnects the peer identified by 'id', removing it from the list of connected peers, and closing the underlying connection with it.

func (Instance) GetAuthenticatingPeers

func (self Instance) GetAuthenticatingPeers() []int32

Returns the IDs of the peers currently trying to authenticate with this graphics.gd/classdb/MultiplayerAPI.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) MaxDeltaPacketSize

func (self Instance) MaxDeltaPacketSize() int

func (Instance) MaxSyncPacketSize

func (self Instance) MaxSyncPacketSize() int

func (Instance) OnPeerAuthenticating

func (self Instance) OnPeerAuthenticating(cb func(id int), flags ...Signal.Flags)

func (Instance) OnPeerAuthenticationFailed

func (self Instance) OnPeerAuthenticationFailed(cb func(id int), flags ...Signal.Flags)

func (Instance) OnPeerPacket

func (self Instance) OnPeerPacket(cb func(id int, packet []byte), flags ...Signal.Flags)

func (Instance) RefuseNewConnections

func (self Instance) RefuseNewConnections() bool

func (Instance) RootPath

func (self Instance) RootPath() string

func (Instance) SendAuth

func (self Instance) SendAuth(id int, data []byte) error

Sends the specified 'data' to the remote peer identified by 'id' as part of an authentication message. This can be used to authenticate peers, and control when [Instance.OnMultiplayerapi.PeerConnected] is emitted (and the remote peer accepted as one of the connected peers).

func (Instance) SendBytes

func (self Instance) SendBytes(bytes []byte) error

Sends the given raw 'bytes' to a specific peer identified by 'id' (see graphics.gd/classdb/MultiplayerPeer.Instance.SetTargetPeer). Default ID is 0, i.e. broadcast to all peers.

func (Instance) ServerRelay

func (self Instance) ServerRelay() bool

func (Instance) SetAllowObjectDecoding

func (self Instance) SetAllowObjectDecoding(value bool)

func (Instance) SetAuthCallback

func (self Instance) SetAuthCallback(value Callable.Function)

func (Instance) SetAuthTimeout

func (self Instance) SetAuthTimeout(value Float.X)

func (Instance) SetMaxDeltaPacketSize

func (self Instance) SetMaxDeltaPacketSize(value int)

func (Instance) SetMaxSyncPacketSize

func (self Instance) SetMaxSyncPacketSize(value int)

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) SetRefuseNewConnections

func (self Instance) SetRefuseNewConnections(value bool)

func (Instance) SetRootPath

func (self Instance) SetRootPath(value string)

func (Instance) SetServerRelay

func (self Instance) SetServerRelay(value bool)

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL