WebSocketMultiplayerPeer
Base class for WebSocket server and client.
WebSocketMultiplayerPeer.swift:14class WebSocketMultiplayerPeer
Base class for WebSocket server and client, allowing them to be used as multiplayer peer for the MultiplayerAPI
.
Superclasses
class MultiplayerPeer
Abstract class for specialized
PacketPeer
s used by theMultiplayerAPI
.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var handshakeHeaders: PackedStringArray
The extra headers to use during handshake. See
handshakeHeaders
for more details.var handshakeTimeout: Double
The maximum time each peer can stay in a connecting state before being dropped.
var inboundBufferSize: Int32
The inbound buffer size for connected peers. See
inboundBufferSize
for more details.var maxQueuedPackets: Int32
The maximum number of queued packets for connected peers. See
maxQueuedPackets
for more details.var outboundBufferSize: Int32
The outbound buffer size for connected peers. See
outboundBufferSize
for more details.var supportedProtocols: PackedStringArray
The supported WebSocket sub-protocols. See
supportedProtocols
for more details.func createClient(url: String, tlsClientOptions: TLSOptions?
) -> GodotError Starts a new multiplayer client connecting to the given
url
. TLS certificates will be verified against the hostname when connecting using thewss://
protocol. You can pass the optionaltlsClientOptions
parameter to customize the trusted certification authorities, or disable the common name verification. Seeclient(trustedChain:commonNameOverride:)
andclientUnsafe(trustedChain:)
.func createServer(port: Int32, bindAddress: String, tlsServerOptions: TLSOptions?
) -> GodotError Starts a new multiplayer server listening on the given
port
. You can optionally specify abindAddress
, and provide validtlsServerOptions
to use TLS. Seeserver(key:certificate:)
.func getPeer(peerId: Int32
) -> WebSocketPeer? Returns the
WebSocketPeer
associated to the givenpeerId
.func getPeerAddress(id: Int32
) -> String Returns the IP address of the given peer.
func getPeerPort(id: Int32
) -> Int32 Returns the remote port of the given peer.