CompressionMode
ENetConnection.swift:19enum CompressionModeenum CompressionModeimport SwiftGodotFramework to write Godot Game Extensions using the Swift Programming Language.
class ENetConnectionA wrapper class for an ENetHost.
case noneNo compression. This uses the most bandwidth, but has the upside of requiring the fewest CPU resources. This option may also be used to make network debugging using tools like Wireshark easier.
case rangeCoderENet’s built-in range encoding. Works well on small packets, but is not the most efficient algorithm on packets larger than 4 KB.
case fastlzFastLZ compression. This option uses less CPU resources compared to .compressZlib, at the expense of using more bandwidth.
case zlibZlib compression. This option uses less bandwidth compared to .compressFastlz, at the expense of using more CPU resources.
case zstdZstandard compression. Note that this algorithm is not very efficient on packets smaller than 4 KB. Therefore, it’s recommended to use other compression algorithms in most cases.
override class var godotClassName: StringName { get }final func bandwidthLimit(inBandwidth: Int32 = 0, outBandwidth: Int32 = 0) Adjusts the bandwidth limits of a host.
final func broadcast(channel: Int32, packet: PackedByteArray, flags: Int32) Queues a packet to be sent to all peers associated with the host over the specified channel. See ENetPacketPeer FLAG_* constants for available packet flags.
final func channelLimit(_ limit: Int32) Limits the maximum allowed channels of future incoming connections.
final 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.
final func connectToHost(address: String, port: Int32, channels: Int32 = 0, data: Int32 = 0) -> ENetPacketPeer? Initiates a connection to a foreign address using the specified port and allocating the requested channels. Optional data can be passed during connection in the form of a 32 bit integer.
final func createHost(maxPeers: Int32 = 32, maxChannels: Int32 = 0, inBandwidth: Int32 = 0, outBandwidth: Int32 = 0) -> GodotError Create an ENetHost that will allow up to maxPeers connected peers, each allocating up to maxChannels channels, optionally limiting bandwidth to inBandwidth and outBandwidth.
final func createHostBound(bindAddress: String, bindPort: Int32, maxPeers: Int32 = 32, maxChannels: Int32 = 0, inBandwidth: Int32 = 0, outBandwidth: Int32 = 0) -> GodotError Create an ENetHost like createHost(maxPeers:maxChannels:inBandwidth:outBandwidth:) which is also bound to the given bindAddress and bindPort.
final func destroy() Destroys the host and all resources associated with it.
final func dtlsClientSetup(hostname: String, clientOptions: TLSOptions? = nil) -> 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 against hostname. You can pass the optional clientOptions parameter to customize the trusted certification authorities, or disable the common name verification. See client(trustedChain:commonNameOverride:) and clientUnsafe(trustedChain:).
final 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. See server(key:certificate:).
final func flush() Sends any queued packets on the host specified to its designated peers.
final func getLocalPort() -> Int32 Returns the local port to which this peer is bound.
final func getMaxChannels() -> Int32 Returns the maximum number of channels allowed for connected peers.
final func getPeers() -> ObjectCollection<ENetPacketPeer> Returns the list of peers associated with this host.
final func popStatistic(_ statistic: ENetConnection.HostStatistic) -> Double Returns and resets host statistics. See HostStatistic for more info.
final func refuseNewConnections(refuse: Bool) Configures the DTLS server to automatically drop new connections.
final func service(timeout: Int32 = 0) -> GArray Waits for events on the host specified and shuttles packets between the host and its peers. The returned GArray will have 4 elements. An EventType, the ENetPacketPeer 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 associated ENetPacketPeer.
final 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.
enum EventTypeenum HostStatisticprotocol CaseIterableA type that provides a collection of all of its values.
protocol CustomDebugStringConvertibleA type with a customized textual representation suitable for debugging purposes.
protocol EquatableA type that can be compared for value equality.
protocol Hashable : EquatableA 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.
init?(rawValue: Int64) var debugDescription: String { get }A textual representation of this instance, suitable for debugging
var hashValue: Int { get }static func != (lhs: Self, rhs: Self) -> Bool Returns a Boolean value indicating whether two values are not equal.
func hash(into hasher: inout Hasher)