Documentation
¶
Overview ¶
Package ENetPacketPeer provides methods for working with ENetPacketPeer object instances.
Index ¶
- type Advanced
- type Any
- type Instance
- func (self Instance) AsENetPacketPeer() Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsPacketPeer() PacketPeer.Instance
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) GetChannels() int
- func (self Instance) GetRemoteAddress() string
- func (self Instance) GetRemotePort() int
- func (self Instance) GetState() gdclass.ENetPacketPeerPeerState
- func (self Instance) GetStatistic(statistic gdclass.ENetPacketPeerPeerStatistic) Float.X
- func (self Instance) IsActive() bool
- func (self Instance) PeerDisconnect()
- func (self Instance) PeerDisconnectLater()
- func (self Instance) PeerDisconnectNow()
- func (self Instance) Ping()
- func (self Instance) PingInterval(ping_interval int)
- func (self Instance) Reset()
- func (self Instance) Send(channel int, packet []byte, flags int) error
- func (self Instance) SetTimeout(timeout int, timeout_min int, timeout_max int)
- func (self Instance) ThrottleConfigure(interval int, acceleration int, deceleration int)
- func (self *Instance) UnsafePointer() unsafe.Pointer
- func (self Instance) Virtual(name string) reflect.Value
- type PeerState
- type PeerStatistic
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Instance ¶
type Instance [1]gdclass.ENetPacketPeer
A PacketPeer implementation representing a peer of an [ENetConnection]. This class cannot be instantiated directly but can be retrieved during [method ENetConnection.service] or via [method ENetConnection.get_peers]. [b]Note:[/b] When exporting to Android, make sure to enable the [code]INTERNET[/code] permission in the Android export preset before exporting the project or using one-click deploy. Otherwise, network communication of any kind will be blocked by Android.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsENetPacketPeer ¶
func (Instance) AsPacketPeer ¶
func (self Instance) AsPacketPeer() PacketPeer.Instance
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) GetChannels ¶
Returns the number of channels allocated for communication with peer.
func (Instance) GetRemoteAddress ¶
Returns the IP address of this peer.
func (Instance) GetRemotePort ¶
Returns the remote port of this peer.
func (Instance) GetState ¶
func (self Instance) GetState() gdclass.ENetPacketPeerPeerState
Returns the current peer state. See [enum PeerState].
func (Instance) GetStatistic ¶
func (self Instance) GetStatistic(statistic gdclass.ENetPacketPeerPeerStatistic) Float.X
Returns the requested [param statistic] for this peer. See [enum PeerStatistic].
func (Instance) IsActive ¶
Returns [code]true[/code] if the peer is currently active (i.e. the associated [ENetConnection] is still valid).
func (Instance) PeerDisconnect ¶
func (self Instance) PeerDisconnect()
Request a disconnection from a peer. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete.
func (Instance) PeerDisconnectLater ¶
func (self Instance) PeerDisconnectLater()
Request a disconnection from a peer, but only after all queued outgoing packets are sent. An [constant ENetConnection.EVENT_DISCONNECT] will be generated during [method ENetConnection.service] once the disconnection is complete.
func (Instance) PeerDisconnectNow ¶
func (self Instance) PeerDisconnectNow()
Force an immediate disconnection from a peer. No [constant ENetConnection.EVENT_DISCONNECT] will be generated. The foreign peer is not guaranteed to receive the disconnect notification, and is reset immediately upon return from this function.
func (Instance) Ping ¶
func (self Instance) 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 (Instance) PingInterval ¶
Sets the [param ping_interval] 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 is [code]500[/code] milliseconds.
func (Instance) Reset ¶
func (self Instance) 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 (Instance) Send ¶
Queues a [param packet] to be sent over the specified [param channel]. See [code]FLAG_*[/code] constants for available packet flags.
func (Instance) SetTimeout ¶
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. The [param 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 [param timeout_min]. The [param timeout_max] parameter, on the other hand, defines a fixed timeout for which any packet must be acknowledged or the peer will be dropped.
func (Instance) ThrottleConfigure ¶
Configures throttle parameter for a peer. 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 [param interval], ENet will either increase the probability by the amount specified in the [param acceleration] parameter, or decrease it by the amount specified in the [param deceleration] parameter (both are ratios to [constant PACKET_THROTTLE_SCALE]). When the throttle has a value of [constant PACKET_THROTTLE_SCALE], no unreliable packets are dropped by ENet, and so 100% of all unreliable packets will be sent. When the throttle has a value of [code]0[/code], 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.
func (*Instance) UnsafePointer ¶
type PeerState ¶
type PeerState = gdclass.ENetPacketPeerPeerState //gd:ENetPacketPeer.PeerState
const ( /*The peer is disconnected.*/ StateDisconnected PeerState = 0 /*The peer is currently attempting to connect.*/ StateConnecting PeerState = 1 /*The peer has acknowledged the connection request.*/ StateAcknowledgingConnect PeerState = 2 /*The peer is currently connecting.*/ StateConnectionPending PeerState = 3 /*The peer has successfully connected, but is not ready to communicate with yet ([constant STATE_CONNECTED]).*/ StateConnectionSucceeded PeerState = 4 /*The peer is currently connected and ready to communicate with.*/ StateConnected PeerState = 5 /*The peer is slated to disconnect after it has no more outgoing packets to send.*/ StateDisconnectLater PeerState = 6 /*The peer is currently disconnecting.*/ StateDisconnecting PeerState = 7 /*The peer has acknowledged the disconnection request.*/ StateAcknowledgingDisconnect PeerState = 8 /*The peer has lost connection, but is not considered truly disconnected (as the peer didn't acknowledge the disconnection request).*/ StateZombie PeerState = 9 )
type PeerStatistic ¶
type PeerStatistic = gdclass.ENetPacketPeerPeerStatistic //gd:ENetPacketPeer.PeerStatistic
const ( /*Mean packet loss of reliable packets as a ratio with respect to the [constant PACKET_LOSS_SCALE].*/ PeerPacketLoss PeerStatistic = 0 /*Packet loss variance.*/ PeerPacketLossVariance PeerStatistic = 1 /*The time at which packet loss statistics were last updated (in milliseconds since the connection started). The interval for packet loss statistics updates is 10 seconds, and at least one packet must have been sent since the last statistics update.*/ PeerPacketLossEpoch PeerStatistic = 2 /*Mean packet round trip time for reliable packets.*/ PeerRoundTripTime PeerStatistic = 3 /*Variance of the mean round trip time.*/ PeerRoundTripTimeVariance PeerStatistic = 4 /*Last recorded round trip time for a reliable packet.*/ PeerLastRoundTripTime PeerStatistic = 5 /*Variance of the last trip time recorded.*/ PeerLastRoundTripTimeVariance PeerStatistic = 6 /*The peer's current throttle status.*/ PeerPacketThrottle PeerStatistic = 7 /*The maximum number of unreliable packets that should not be dropped. This value is always greater than or equal to [code]1[/code]. The initial value is equal to [constant PACKET_THROTTLE_SCALE].*/ PeerPacketThrottleLimit PeerStatistic = 8 /*Internal value used to increment the packet throttle counter. The value is hardcoded to [code]7[/code] and cannot be changed. You probably want to look at [constant PEER_PACKET_THROTTLE_ACCELERATION] instead.*/ PeerPacketThrottleCounter PeerStatistic = 9 /*The time at which throttle statistics were last updated (in milliseconds since the connection started). The interval for throttle statistics updates is [constant PEER_PACKET_THROTTLE_INTERVAL].*/ PeerPacketThrottleEpoch PeerStatistic = 10 /*The throttle's acceleration factor. Higher values will make ENet adapt to fluctuating network conditions faster, causing unrelaible packets to be sent [i]more[/i] often. The default value is [code]2[/code].*/ PeerPacketThrottleAcceleration PeerStatistic = 11 /*The throttle's deceleration factor. Higher values will make ENet adapt to fluctuating network conditions faster, causing unrelaible packets to be sent [i]less[/i] often. The default value is [code]2[/code].*/ PeerPacketThrottleDeceleration PeerStatistic = 12 /*The interval over which the lowest mean round trip time should be measured for use by the throttle mechanism (in milliseconds). The default value is [code]5000[/code].*/ PeerPacketThrottleInterval PeerStatistic = 13 )