Documentation ¶
Overview ¶
Package MultiplayerAPI provides methods for working with MultiplayerAPI object instances.
Index ¶
- func CreateDefaultInterface() [1]gdclass.MultiplayerAPI
- func GetDefaultInterface() string
- func SetDefaultInterface(interface_name string)
- type Advanced
- type Any
- type Error
- type Instance
- func (self Instance) AsMultiplayerAPI() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) GetPeers() []int32
- func (self Instance) GetRemoteSenderId() int
- func (self Instance) GetUniqueId() int
- func (self Instance) HasMultiplayerPeer() bool
- func (self Instance) IsServer() bool
- func (self Instance) MultiplayerPeer() [1]gdclass.MultiplayerPeer
- func (self Instance) ObjectConfigurationAdd(obj Object.Instance, configuration any) error
- func (self Instance) ObjectConfigurationRemove(obj Object.Instance, configuration any) error
- func (self Instance) OnConnectedToServer(cb func())
- func (self Instance) OnConnectionFailed(cb func())
- func (self Instance) OnPeerConnected(cb func(id int))
- func (self Instance) OnPeerDisconnected(cb func(id int))
- func (self Instance) OnServerDisconnected(cb func())
- func (self Instance) Poll() error
- func (self Instance) Rpc(peer int, obj Object.Instance, method string) error
- func (self Instance) SetMultiplayerPeer(value [1]gdclass.MultiplayerPeer)
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
- type RPCMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDefaultInterface ¶
func CreateDefaultInterface() [1]gdclass.MultiplayerAPI
Returns a new instance of the default MultiplayerAPI.
func GetDefaultInterface ¶
func GetDefaultInterface() string
Returns the default MultiplayerAPI implementation class name. This is usually [code]"SceneMultiplayer"[/code] when [SceneMultiplayer] is available. See [method set_default_interface].
func SetDefaultInterface ¶
func SetDefaultInterface(interface_name string)
Sets the default MultiplayerAPI implementation class. This method can be used by modules and extensions to configure which implementation will be used by [SceneTree] when the engine starts.
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 Error ¶
const ( /*Methods that return [enum Error] return [constant OK] when no error occurred. Since [constant OK] has value 0, and all other error constants are positive integers, it can also be used in boolean checks. [b]Example:[/b] [codeblock] var error = method_that_returns_error() if error != OK: printerr("Failure!") # Or, alternatively: if error: printerr("Still failing!") [/codeblock] [b]Note:[/b] Many functions do not return an error code, but will print error messages to standard output.*/ Ok Error = 0 /*Generic error.*/ Failed Error = 1 ErrUnavailable Error = 2 /*Unconfigured error.*/ ErrUnconfigured Error = 3 ErrUnauthorized Error = 4 /*Parameter range error.*/ ErrParameterRangeError Error = 5 /*Out of memory (OOM) error.*/ ErrOutOfMemory Error = 6 /*File: Not found error.*/ ErrFileNotFound Error = 7 /*File: Bad drive error.*/ ErrFileBadDrive Error = 8 /*File: Bad path error.*/ ErrFileBadPath Error = 9 /*File: No permission error.*/ ErrFileNoPermission Error = 10 /*File: Already in use error.*/ ErrFileAlreadyInUse Error = 11 /*File: Can't open error.*/ ErrFileCantOpen Error = 12 /*File: Can't write error.*/ ErrFileCantWrite Error = 13 /*File: Can't read error.*/ ErrFileCantRead Error = 14 /*File: Unrecognized error.*/ ErrFileUnrecognized Error = 15 /*File: Corrupt error.*/ ErrFileCorrupt Error = 16 /*File: Missing dependencies error.*/ ErrFileMissingDependencies Error = 17 /*File: End of file (EOF) error.*/ ErrFileEof Error = 18 /*Can't open error.*/ ErrCantOpen Error = 19 /*Can't create error.*/ ErrCantCreate Error = 20 /*Query failed error.*/ ErrQueryFailed Error = 21 /*Already in use error.*/ ErrAlreadyInUse Error = 22 /*Locked error.*/ ErrLocked Error = 23 /*Timeout error.*/ ErrTimeout Error = 24 /*Can't connect error.*/ ErrCantConnect Error = 25 /*Can't resolve error.*/ ErrCantResolve Error = 26 /*Connection error.*/ ErrConnectionError Error = 27 /*Can't acquire resource error.*/ ErrCantAcquireResource Error = 28 /*Can't fork process error.*/ ErrCantFork Error = 29 /*Invalid data error.*/ ErrInvalidData Error = 30 /*Invalid parameter error.*/ ErrInvalidParameter Error = 31 /*Already exists error.*/ ErrAlreadyExists Error = 32 /*Does not exist error.*/ ErrDoesNotExist Error = 33 /*Database: Read error.*/ ErrDatabaseCantRead Error = 34 /*Database: Write error.*/ ErrDatabaseCantWrite Error = 35 /*Compilation failed error.*/ ErrCompilationFailed Error = 36 /*Method not found error.*/ ErrMethodNotFound Error = 37 /*Linking failed error.*/ ErrLinkFailed Error = 38 /*Script failed error.*/ ErrScriptFailed Error = 39 /*Cycling link (import cycle) error.*/ ErrCyclicLink Error = 40 /*Invalid declaration error.*/ ErrInvalidDeclaration Error = 41 /*Duplicate symbol error.*/ ErrDuplicateSymbol Error = 42 /*Parse error.*/ ErrParseError Error = 43 /*Busy error.*/ ErrBusy Error = 44 /*Skip error.*/ ErrSkip Error = 45 /*Help error. Used internally when passing [code]--version[/code] or [code]--help[/code] as executable options.*/ ErrHelp Error = 46 /*Bug error, caused by an implementation issue in the method. [b]Note:[/b] If a built-in method returns this code, please open an issue on [url=https://github.com/godotengine/godot/issues]the GitHub Issue Tracker[/url].*/ ErrBug Error = 47 /*Printer on fire error (This is an easter egg, no built-in methods return this error code).*/ ErrPrinterOnFire Error = 48 )
type Instance ¶
type Instance [1]gdclass.MultiplayerAPI
Base class for high-level multiplayer API implementations. See also [MultiplayerPeer]. By default, [SceneTree] has a reference to an implementation of this class and uses it to provide multiplayer capabilities (i.e. RPCs) across the whole scene. It is possible to override the MultiplayerAPI instance used by specific tree branches by calling the [method SceneTree.set_multiplayer] method, effectively allowing to run both client and server in the same scene. It is also possible to extend or replace the default implementation via scripting or native extensions. See [MultiplayerAPIExtension] for details about extensions, [SceneMultiplayer] for the details about the default implementation.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsMultiplayerAPI ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) GetPeers ¶
Returns the peer IDs of all connected peers of this MultiplayerAPI's [member multiplayer_peer].
func (Instance) GetRemoteSenderId ¶
Returns the sender's peer ID for the RPC currently being executed. [b]Note:[/b] This method returns [code]0[/code] when called outside of an RPC. As such, the original peer ID may be lost when code execution is delayed (such as with GDScript's [code]await[/code] keyword).
func (Instance) GetUniqueId ¶
Returns the unique peer ID of this MultiplayerAPI's [member multiplayer_peer].
func (Instance) HasMultiplayerPeer ¶
Returns [code]true[/code] if there is a [member multiplayer_peer] set.
func (Instance) IsServer ¶
Returns [code]true[/code] if this MultiplayerAPI's [member multiplayer_peer] is valid and in server mode (listening for connections).
func (Instance) MultiplayerPeer ¶
func (self Instance) MultiplayerPeer() [1]gdclass.MultiplayerPeer
func (Instance) ObjectConfigurationAdd ¶
Notifies the MultiplayerAPI of a new [param configuration] for the given [param object]. This method is used internally by [SceneTree] to configure the root path for this MultiplayerAPI (passing [code]null[/code] and a valid [NodePath] as [param configuration]). This method can be further used by MultiplayerAPI implementations to provide additional features, refer to specific implementation (e.g. [SceneMultiplayer]) for details on how they use it. [b]Note:[/b] This method is mostly relevant when extending or overriding the MultiplayerAPI behavior via [MultiplayerAPIExtension].
func (Instance) ObjectConfigurationRemove ¶
Notifies the MultiplayerAPI to remove a [param configuration] for the given [param object]. This method is used internally by [SceneTree] to configure the root path for this MultiplayerAPI (passing [code]null[/code] and an empty [NodePath] as [param configuration]). This method can be further used by MultiplayerAPI implementations to provide additional features, refer to specific implementation (e.g. [SceneMultiplayer]) for details on how they use it. [b]Note:[/b] This method is mostly relevant when extending or overriding the MultiplayerAPI behavior via [MultiplayerAPIExtension].
func (Instance) OnConnectedToServer ¶
func (self Instance) OnConnectedToServer(cb func())
func (Instance) OnConnectionFailed ¶
func (self Instance) OnConnectionFailed(cb func())
func (Instance) OnPeerConnected ¶
func (Instance) OnPeerDisconnected ¶
func (Instance) OnServerDisconnected ¶
func (self Instance) OnServerDisconnected(cb func())
func (Instance) Poll ¶
Method used for polling the MultiplayerAPI. You only need to worry about this if you set [member SceneTree.multiplayer_poll] to [code]false[/code]. By default, [SceneTree] will poll its MultiplayerAPI(s) for you. [b]Note:[/b] This method results in RPCs being called, so they will be executed in the same context of this function (e.g. [code]_process[/code], [code]physics[/code], [Thread]).
func (Instance) Rpc ¶
Sends an RPC to the target [param peer]. The given [param method] will be called on the remote [param object] with the provided [param arguments]. The RPC may also be called locally depending on the implementation and RPC configuration. See [method Node.rpc] and [method Node.rpc_config]. [b]Note:[/b] Prefer using [method Node.rpc], [method Node.rpc_id], or [code]my_method.rpc(peer, arg1, arg2, ...)[/code] (in GDScript), since they are faster. This method is mostly useful in conjunction with [MultiplayerAPIExtension] when augmenting or replacing the multiplayer capabilities.
func (Instance) SetMultiplayerPeer ¶
func (self Instance) SetMultiplayerPeer(value [1]gdclass.MultiplayerPeer)
func (*Instance) UnsafePointer ¶
type RPCMode ¶
type RPCMode = gdclass.MultiplayerAPIRPCMode //gd:MultiplayerAPI.RPCMode
const ( /*Used with [method Node.rpc_config] to disable a method or property for all RPC calls, making it unavailable. Default for all methods.*/ RpcModeDisabled RPCMode = 0 /*Used with [method Node.rpc_config] to set a method to be callable remotely by any peer. Analogous to the [code]@rpc("any_peer")[/code] annotation. Calls are accepted from all remote peers, no matter if they are node's authority or not.*/ RpcModeAnyPeer RPCMode = 1 /*Used with [method Node.rpc_config] to set a method to be callable remotely only by the current multiplayer authority (which is the server by default). Analogous to the [code]@rpc("authority")[/code] annotation. See [method Node.set_multiplayer_authority].*/ RpcModeAuthority RPCMode = 2 )