Documentation
¶
Overview ¶
Base class for WebSocket server and client, allowing them to be used as multiplayer peer for the graphics.gd/classdb/MultiplayerAPI.
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
- func (self *Extension[T]) AsMultiplayerPeer() MultiplayerPeer.Instance
- func (self *Extension[T]) AsObject() [1]gd.Object
- func (self *Extension[T]) AsPacketPeer() PacketPeer.Instance
- func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
- func (self *Extension[T]) AsWebSocketMultiplayerPeer() Instance
- type ID
- type Instance
- func (self Instance) AsMultiplayerPeer() MultiplayerPeer.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPacketPeer() PacketPeer.Instance
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsWebSocketMultiplayerPeer() Instance
- func (self Instance) CreateClient(url string) error
- func (self Instance) CreateServer(port int) error
- func (self Instance) GetPeer(peer_id int) WebSocketPeer.Instance
- func (self Instance) GetPeerAddress(id int) string
- func (self Instance) GetPeerPort(id int) int
- func (self Instance) HandshakeHeaders() []string
- func (self Instance) HandshakeTimeout() Float.X
- func (self Instance) ID() ID
- func (self Instance) InboundBufferSize() int
- func (self Instance) MaxQueuedPackets() int
- func (self Instance) OutboundBufferSize() int
- func (self Instance) SetHandshakeHeaders(value []string)
- func (self Instance) SetHandshakeTimeout(value Float.X)
- func (self Instance) SetInboundBufferSize(value int)
- func (self Instance) SetMaxQueuedPackets(value int)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOutboundBufferSize(value int)
- func (self Instance) SetSupportedProtocols(value []string)
- func (self Instance) SupportedProtocols() []string
- 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.WebSocketMultiplayerPeer
func (Expanded) CreateClient ¶
func (self Expanded) CreateClient(url string, tls_client_options TLSOptions.Instance) error
Starts a new multiplayer client connecting to the given 'url'. TLS certificates will be verified against the hostname when connecting using the wss:// protocol. You can pass the optional 'tls_client_options' parameter to customize the trusted certification authorities, or disable the common name verification. See graphics.gd/classdb/TLSOptions.Instance.Client and graphics.gd/classdb/TLSOptions.Instance.ClientUnsafe.
Note: It is recommended to specify the scheme part of the URL, i.e. the 'url' should start with either ws:// or wss://.
func (Expanded) CreateServer ¶
func (self Expanded) CreateServer(port int, bind_address string, tls_server_options TLSOptions.Instance) error
Starts a new multiplayer server listening on the given 'port'. You can optionally specify a 'bind_address', and provide valid 'tls_server_options' to use TLS. See graphics.gd/classdb/TLSOptions.Instance.Server.
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]) AsMultiplayerPeer ¶
func (self *Extension[T]) AsMultiplayerPeer() MultiplayerPeer.Instance
func (*Extension[T]) AsPacketPeer ¶
func (self *Extension[T]) AsPacketPeer() PacketPeer.Instance
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsWebSocketMultiplayerPeer ¶
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.WebSocketMultiplayerPeer
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) AsMultiplayerPeer ¶
func (self Instance) AsMultiplayerPeer() MultiplayerPeer.Instance
func (Instance) AsPacketPeer ¶
func (self Instance) AsPacketPeer() PacketPeer.Instance
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsWebSocketMultiplayerPeer ¶
func (Instance) CreateClient ¶
Starts a new multiplayer client connecting to the given 'url'. TLS certificates will be verified against the hostname when connecting using the wss:// protocol. You can pass the optional 'tls_client_options' parameter to customize the trusted certification authorities, or disable the common name verification. See graphics.gd/classdb/TLSOptions.Instance.Client and graphics.gd/classdb/TLSOptions.Instance.ClientUnsafe.
Note: It is recommended to specify the scheme part of the URL, i.e. the 'url' should start with either ws:// or wss://.
func (Instance) CreateServer ¶
Starts a new multiplayer server listening on the given 'port'. You can optionally specify a 'bind_address', and provide valid 'tls_server_options' to use TLS. See graphics.gd/classdb/TLSOptions.Instance.Server.
func (Instance) GetPeer ¶
func (self Instance) GetPeer(peer_id int) WebSocketPeer.Instance
Returns the graphics.gd/classdb/WebSocketPeer associated to the given 'peer_id'.
func (Instance) GetPeerAddress ¶
Returns the IP address of the given peer.
func (Instance) GetPeerPort ¶
Returns the remote port of the given peer.