Enumerationmigueldeicaza.swiftgodot 0.46.0SwiftGodot
HostStatistic
ENetConnection.swift:69enum HostStatistic
Cases
case sentData
Total data sent.
case sentPackets
Total UDP packets sent.
case receivedData
Total data received.
case receivedPackets
Total UDP packets received.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (21) members.
Types
Type members
Instance members
func bandwidthLimit(inBandwidth: Int32, outBandwidth: Int32
) Adjusts the bandwidth limits of a host.
func broadcast(channel: Int32, packet: PackedByteArray, flags: Int32
) Queues a
packet
to be sent to all peers associated with the host over the specifiedchannel
. SeeENetPacketPeer
FLAG_*
constants for available packet flags.func channelLimit(Int32
) Limits the maximum allowed channels of future incoming connections.
func compress(mode: ENetConnection.CompressionMode
) Sets the compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all.
func connectToHost(address: String, port: Int32, channels: Int32, data: Int32
) -> ENetPacketPeer? Initiates a connection to a foreign
address
using the specifiedport
and allocating the requestedchannels
. Optionaldata
can be passed during connection in the form of a 32 bit integer.func createHost(maxPeers: Int32, maxChannels: Int32, inBandwidth: Int32, outBandwidth: Int32
) -> GodotError Create an ENetHost that will allow up to
maxPeers
connected peers, each allocating up tomaxChannels
channels, optionally limiting bandwidth toinBandwidth
andoutBandwidth
.func createHostBound(bindAddress: String, bindPort: Int32, maxPeers: Int32, maxChannels: Int32, inBandwidth: Int32, outBandwidth: Int32
) -> GodotError Create an ENetHost like
createHost(maxPeers:maxChannels:inBandwidth:outBandwidth:)
which is also bound to the givenbindAddress
andbindPort
.func destroy(
) Destroys the host and all resources associated with it.
func dtlsClientSetup(hostname: String, clientOptions: TLSOptions?
) -> GodotError Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet clients. Call this before
connectToHost(address:port:channels:data:)
to have ENet connect using DTLS validating the server certificate againsthostname
. You can pass the optionalclientOptions
parameter to customize the trusted certification authorities, or disable the common name verification. Seeclient(trustedChain:commonNameOverride:)
andclientUnsafe(trustedChain:)
.func dtlsServerSetup(serverOptions: TLSOptions?
) -> GodotError Configure this ENetHost to use the custom Godot extension allowing DTLS encryption for ENet servers. Call this right after
createHostBound(bindAddress:bindPort:maxPeers:maxChannels:inBandwidth:outBandwidth:)
to have ENet expect peers to connect using DTLS. Seeserver(key:certificate:)
.func flush(
) Sends any queued packets on the host specified to its designated peers.
func getLocalPort(
) -> Int32 Returns the local port to which this peer is bound.
func getMaxChannels(
) -> Int32 Returns the maximum number of channels allowed for connected peers.
func getPeers(
) -> ObjectCollection<ENetPacketPeer> Returns the list of peers associated with this host.
func popStatistic(ENetConnection.HostStatistic
) -> Double Returns and resets host statistics. See
HostStatistic
for more info.func refuseNewConnections(refuse: Bool
) Configures the DTLS server to automatically drop new connections.
func service(timeout: Int32
) -> GArray Waits for events on the host specified and shuttles packets between the host and its peers. The returned
GArray
will have 4 elements. AnEventType
, theENetPacketPeer
which generated the event, the event associated data (if any), the event associated channel (if any). If the generated event is .eventReceive, the received packet will be queued to the associatedENetPacketPeer
.func socketSend(destinationAddress: String, destinationPort: Int32, packet: PackedByteArray
) Sends a
packet
toward a destination from the address and port currently bound by this ENetConnection instance.
Citizens in SwiftGodot
Conformances
protocol CaseIterable
A type that provides a collection of all of its values.
protocol CustomDebugStringConvertible
A type with a customized textual representation suitable for debugging purposes.
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 RawRepresentable<RawValue>
A type that can be converted to and from an associated raw value.
Type members
Instance members
var debugDescription: String
A textual representation of this instance, suitable for debugging
Type features
static func != (lhs: Self, rhs: Self
) -> Bool Returns a Boolean value indicating whether two values are not equal.