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 ¶
- type Advanced
- type Any
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AllowObjectDecoding() bool
- func (self Instance) AsMultiplayerAPI() MultiplayerAPI.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsSceneMultiplayer() Instance
- func (self Instance) AuthCallback() Callable.Function
- func (self Instance) AuthTimeout() Float.X
- func (self Instance) Clear()
- func (self Instance) CompleteAuth(id int) error
- func (self Instance) DisconnectPeer(id int)
- func (self Instance) GetAuthenticatingPeers() []int32
- func (self Instance) ID() ID
- func (self Instance) MaxDeltaPacketSize() int
- func (self Instance) MaxSyncPacketSize() int
- func (self Instance) OnPeerAuthenticating(cb func(id int), flags ...Signal.Flags)
- func (self Instance) OnPeerAuthenticationFailed(cb func(id int), flags ...Signal.Flags)
- func (self Instance) OnPeerPacket(cb func(id int, packet []byte), flags ...Signal.Flags)
- func (self Instance) RefuseNewConnections() bool
- func (self Instance) RootPath() string
- func (self Instance) SendAuth(id int, data []byte) error
- func (self Instance) SendBytes(bytes []byte) error
- func (self Instance) ServerRelay() bool
- func (self Instance) SetAllowObjectDecoding(value bool)
- func (self Instance) SetAuthCallback(value Callable.Function)
- func (self Instance) SetAuthTimeout(value Float.X)
- func (self Instance) SetMaxDeltaPacketSize(value int)
- func (self Instance) SetMaxSyncPacketSize(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetRefuseNewConnections(value bool)
- func (self Instance) SetRootPath(value string)
- func (self Instance) SetServerRelay(value bool)
- func (self Instance) Virtual(name string) reflect.Value
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 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 ¶
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]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsSceneMultiplayer ¶
type 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.
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 (Instance) AllowObjectDecoding ¶
func (Instance) AsMultiplayerAPI ¶
func (self Instance) AsMultiplayerAPI() MultiplayerAPI.Instance
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsSceneMultiplayer ¶
func (Instance) AuthCallback ¶
func (Instance) AuthTimeout ¶
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 ¶
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 ¶
Disconnects the peer identified by 'id', removing it from the list of connected peers, and closing the underlying connection with it.
func (Instance) GetAuthenticatingPeers ¶
Returns the IDs of the peers currently trying to authenticate with this graphics.gd/classdb/MultiplayerAPI.
func (Instance) MaxDeltaPacketSize ¶
func (Instance) MaxSyncPacketSize ¶
func (Instance) OnPeerAuthenticating ¶
func (Instance) OnPeerAuthenticationFailed ¶
func (Instance) OnPeerPacket ¶
func (Instance) RefuseNewConnections ¶
func (Instance) SendAuth ¶
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 ¶
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.