Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
throttleConfigure(interval:acceleration:deceleration:)
Configures throttle parameter for a peer.
ENetPacketPeer.swift:345final func throttleConfigure(interval: Int32, acceleration: Int32, deceleration: Int32)
Unreliable packets are dropped by ENet in response to the varying conditions of the Internet connection to the peer. The throttle represents a probability that an unreliable packet should not be dropped and thus sent by ENet to the peer. By measuring fluctuations in round trip times of reliable packets over the specified interval
, ENet will either increase the probability by the amount specified in the acceleration
parameter, or decrease it by the amount specified in the deceleration
parameter (both are ratios to packetThrottleScale
).
When the throttle has a value of packetThrottleScale
, no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent.
When the throttle has a value of 0
, all unreliable packets are dropped by ENet, and so 0% of all unreliable packets will be sent.
Intermediate values for the throttle represent intermediate probabilities between 0% and 100% of unreliable packets being sent. The bandwidth limits of the local and foreign hosts are taken into account to determine a sensible limit for the throttle probability above which it should not raise even in the best of conditions.
Other members in extension
Types
Type members
static let flagReliable: Int
Mark the packet to be sent as reliable.
static let flagUnreliableFragment: Int
Mark the packet to be sent unreliable even if the packet is too big and needs fragmentation (increasing the chance of it being dropped).
static let flagUnsequenced: Int
Mark the packet to be sent unsequenced (unreliable).
static let packetLossScale: Int
The reference scale for packet loss. See
getStatistic(_:)
and .peerPacketLoss.static let packetThrottleScale: Int
The reference value for throttle configuration. The default value is
32
. SeethrottleConfigure(interval:acceleration:deceleration:)
.class var godotClassName: StringName
Instance members
func getChannels(
) -> Int32 Returns the number of channels allocated for communication with peer.
func getRemoteAddress(
) -> String Returns the IP address of this peer.
func getRemotePort(
) -> Int32 Returns the remote port of this peer.
func getState(
) -> ENetPacketPeer.PeerState Returns the current peer state. See
PeerState
.func getStatistic(ENetPacketPeer.PeerStatistic
) -> Double Returns the requested
statistic
for this peer. SeePeerStatistic
.func isActive(
) -> Bool Returns
true
if the peer is currently active (i.e. the associatedENetConnection
is still valid).func peerDisconnect(data: Int32
) Request a disconnection from a peer. An
ENetConnection/EventType/eventDisconnect
will be generated duringservice(timeout:)
once the disconnection is complete.func peerDisconnectLater(data: Int32
) Request a disconnection from a peer, but only after all queued outgoing packets are sent. An
ENetConnection/EventType/eventDisconnect
will be generated duringservice(timeout:)
once the disconnection is complete.func peerDisconnectNow(data: Int32
) Force an immediate disconnection from a peer. No
ENetConnection/EventType/eventDisconnect
will be generated. The foreign peer is not guaranteed to receive the disconnect notification, and is reset immediately upon return from this function.func ping(
) Sends a ping request to a peer. ENet automatically pings all connected peers at regular intervals, however, this function may be called to ensure more frequent ping requests.
func pingInterval(pingInterval: Int32
) Sets the
pingInterval
in milliseconds at which pings will be sent to a peer. Pings are used both to monitor the liveness of the connection and also to dynamically adjust the throttle during periods of low traffic so that the throttle has reasonable responsiveness during traffic spikes. The default ping interval is500
milliseconds.func reset(
) Forcefully disconnects a peer. The foreign host represented by the peer is not notified of the disconnection and will timeout on its connection to the local host.
func send(channel: Int32, packet: PackedByteArray, flags: Int32
) -> GodotError Queues a
packet
to be sent over the specifiedchannel
. SeeFLAG_*
constants for available packet flags.func setTimeout(Int32, timeoutMin: Int32, timeoutMax: Int32
) Sets the timeout parameters for a peer. The timeout parameters control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values are expressed in milliseconds.