Instance Methodmigueldeicaza.swiftgodot 0.45.0SwiftGodot
setTimeout(_:timeoutMin:timeoutMax:)
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.
ENetPacketPeer.swift:390final func setTimeout(_ timeout: Int32, timeoutMin: Int32, timeoutMax: Int32)
The timeout
is a factor that, multiplied by a value based on the average round trip time, will determine the timeout limit for a reliable packet. When that limit is reached, the timeout will be doubled, and the peer will be disconnected if that limit has reached timeoutMin
. The timeoutMax
parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
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 throttleConfigure(interval: Int32, acceleration: Int32, deceleration: Int32
) Configures throttle parameter for a peer.