void enet_peer_disconnect | ( | ENetPeer * | peer, |
enet_uint32 | data | ||
) |
#include <peer.c>
Request a disconnection from a peer.
peer | peer to request a disconnection |
data | data describing the disconnection |
References _ENetProtocolCommandHeader::channelID, _ENetProtocolCommandHeader::command, _ENetProtocolDisconnect::data, _ENetProtocol::disconnect, enet_host_flush(), ENET_HOST_TO_NET_32, enet_peer_on_disconnect(), enet_peer_queue_outgoing_command(), enet_peer_reset(), enet_peer_reset_queues(), ENET_PEER_STATE_ACKNOWLEDGING_DISCONNECT, ENET_PEER_STATE_CONNECTED, ENET_PEER_STATE_DISCONNECT_LATER, ENET_PEER_STATE_DISCONNECTED, ENET_PEER_STATE_DISCONNECTING, ENET_PEER_STATE_ZOMBIE, ENET_PROTOCOL_COMMAND_DISCONNECT, ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE, ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED, and _ENetProtocol::header.
Referenced by enet_peer_disconnect_later().
void enet_peer_disconnect_later | ( | ENetPeer * | peer, |
enet_uint32 | data | ||
) |
#include <peer.c>
Request a disconnection from a peer, but only after all queued outgoing packets are sent.
peer | peer to request a disconnection |
data | data describing the disconnection |
References enet_list_empty, enet_peer_disconnect(), ENET_PEER_STATE_CONNECTED, and ENET_PEER_STATE_DISCONNECT_LATER.
void enet_peer_disconnect_now | ( | ENetPeer * | peer, |
enet_uint32 | data | ||
) |
#include <peer.c>
Force an immediate disconnection from a peer.
peer | peer to disconnect |
data | data describing the disconnection |
References _ENetProtocolCommandHeader::channelID, _ENetProtocolCommandHeader::command, _ENetProtocolDisconnect::data, _ENetProtocol::disconnect, enet_host_flush(), ENET_HOST_TO_NET_32, enet_peer_queue_outgoing_command(), enet_peer_reset(), enet_peer_reset_queues(), ENET_PEER_STATE_DISCONNECTED, ENET_PEER_STATE_DISCONNECTING, ENET_PEER_STATE_ZOMBIE, ENET_PROTOCOL_COMMAND_DISCONNECT, ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED, and _ENetProtocol::header.
void enet_peer_dispatch_incoming_reliable_commands | ( | ENetPeer * | peer, |
ENetChannel * | channel | ||
) |
#include <peer.c>
References enet_list_begin, enet_list_empty, enet_list_end, enet_list_insert(), enet_list_move(), enet_list_next, enet_list_previous, and enet_peer_dispatch_incoming_unreliable_commands().
Referenced by enet_peer_queue_incoming_command().
void enet_peer_dispatch_incoming_unreliable_commands | ( | ENetPeer * | peer, |
ENetChannel * | channel | ||
) |
#include <peer.c>
References _ENetIncomingCommand::command, enet_list_begin, enet_list_end, enet_list_insert(), enet_list_move(), enet_list_next, enet_list_previous, ENET_PEER_FREE_RELIABLE_WINDOWS, ENET_PEER_RELIABLE_WINDOW_SIZE, ENET_PEER_RELIABLE_WINDOWS, ENET_PROTOCOL_COMMAND_MASK, and ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED.
Referenced by enet_peer_dispatch_incoming_reliable_commands(), and enet_peer_queue_incoming_command().
#include <peer.c>
References ENET_PEER_STATE_CONNECTED, and ENET_PEER_STATE_DISCONNECT_LATER.
#include <peer.c>
References ENET_PEER_STATE_CONNECTED, and ENET_PEER_STATE_DISCONNECT_LATER.
Referenced by enet_peer_disconnect(), and enet_peer_reset().
#include <peer.c>
Sends a ping request to a peer.
peer | destination for the ping request |
References _ENetProtocolCommandHeader::channelID, _ENetProtocolCommandHeader::command, enet_peer_queue_outgoing_command(), ENET_PEER_STATE_CONNECTED, ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE, ENET_PROTOCOL_COMMAND_PING, and _ENetProtocol::header.
void enet_peer_ping_interval | ( | ENetPeer * | peer, |
enet_uint32 | pingInterval | ||
) |
#include <peer.c>
Sets the interval 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.
peer | the peer to adjust |
pingInterval | the interval at which to send pings; defaults to ENET_PEER_PING_INTERVAL if 0 |
References ENET_PEER_PING_INTERVAL.
ENetAcknowledgement* enet_peer_queue_acknowledgement | ( | ENetPeer * | peer, |
const ENetProtocol * | command, | ||
enet_uint16 | sentTime | ||
) |
#include <peer.c>
References enet_list_end, enet_list_insert(), enet_malloc(), ENET_PEER_FREE_RELIABLE_WINDOWS, ENET_PEER_RELIABLE_WINDOW_SIZE, and ENET_PEER_RELIABLE_WINDOWS.
ENetIncomingCommand* enet_peer_queue_incoming_command | ( | ENetPeer * | peer, |
const ENetProtocol * | command, | ||
const void * | data, | ||
size_t | dataLength, | ||
enet_uint32 | flags, | ||
enet_uint32 | fragmentCount | ||
) |
#include <peer.c>
References enet_free(), enet_list_end, enet_list_insert(), enet_list_next, enet_list_previous, enet_malloc(), ENET_NET_TO_HOST_16, enet_packet_create(), enet_packet_destroy(), enet_peer_dispatch_incoming_reliable_commands(), enet_peer_dispatch_incoming_unreliable_commands(), ENET_PEER_FREE_RELIABLE_WINDOWS, ENET_PEER_RELIABLE_WINDOW_SIZE, ENET_PEER_RELIABLE_WINDOWS, ENET_PEER_STATE_DISCONNECT_LATER, ENET_PROTOCOL_COMMAND_MASK, ENET_PROTOCOL_COMMAND_SEND_FRAGMENT, ENET_PROTOCOL_COMMAND_SEND_RELIABLE, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT, ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED, and ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT.
ENetOutgoingCommand* enet_peer_queue_outgoing_command | ( | ENetPeer * | peer, |
const ENetProtocol * | command, | ||
ENetPacket * | packet, | ||
enet_uint32 | offset, | ||
enet_uint16 | length | ||
) |
#include <peer.c>
References enet_malloc(), and enet_peer_setup_outgoing_command().
Referenced by enet_host_bandwidth_throttle(), enet_host_connect(), enet_peer_disconnect(), enet_peer_disconnect_now(), enet_peer_ping(), enet_peer_send(), and enet_peer_throttle_configure().
ENetPacket* enet_peer_receive | ( | ENetPeer * | peer, |
enet_uint8 * | channelID | ||
) |
#include <peer.c>
Attempts to dequeue any incoming queued packet.
peer | peer to dequeue packets from |
channelID | holds the channel ID of the channel the packet was received on success |
References enet_free(), enet_list_begin, enet_list_empty, and enet_list_remove().
#include <peer.c>
Forcefully disconnects a peer.
peer | peer to forcefully disconnect |
References ENET_PEER_DEFAULT_PACKET_THROTTLE, ENET_PEER_DEFAULT_ROUND_TRIP_TIME, enet_peer_on_disconnect(), ENET_PEER_PACKET_THROTTLE_ACCELERATION, ENET_PEER_PACKET_THROTTLE_DECELERATION, ENET_PEER_PACKET_THROTTLE_INTERVAL, ENET_PEER_PACKET_THROTTLE_SCALE, ENET_PEER_PING_INTERVAL, enet_peer_reset_queues(), ENET_PEER_STATE_DISCONNECTED, ENET_PEER_TIMEOUT_LIMIT, ENET_PEER_TIMEOUT_MAXIMUM, ENET_PEER_TIMEOUT_MINIMUM, ENET_PROTOCOL_MAXIMUM_PEER_ID, and ENET_PROTOCOL_MAXIMUM_WINDOW_SIZE.
Referenced by enet_host_create(), enet_host_destroy(), enet_peer_disconnect(), and enet_peer_disconnect_now().
#include <peer.c>
References enet_free(), enet_list_begin, enet_list_empty, and enet_list_remove().
Referenced by enet_peer_disconnect(), enet_peer_disconnect_now(), and enet_peer_reset().
int enet_peer_send | ( | ENetPeer * | peer, |
enet_uint8 | channelID, | ||
ENetPacket * | packet | ||
) |
#include <peer.c>
Queues a packet to be sent.
peer | destination for the packet |
channelID | channel on which to send |
packet | packet to send |
0 | on success |
< | 0 on failure |
References _ENetProtocolCommandHeader::channelID, _ENetProtocolCommandHeader::command, _ENetProtocolSendReliable::dataLength, _ENetProtocolSendUnreliable::dataLength, _ENetProtocolSendUnsequenced::dataLength, _ENetProtocolSendFragment::dataLength, enet_free(), ENET_HOST_TO_NET_16, ENET_HOST_TO_NET_32, enet_list_begin, enet_list_clear(), enet_list_empty, enet_list_end, enet_list_insert(), enet_list_remove(), enet_malloc(), ENET_NET_TO_HOST_32, ENET_PACKET_FLAG_RELIABLE, ENET_PACKET_FLAG_UNRELIABLE_FRAGMENT, ENET_PACKET_FLAG_UNSEQUENCED, enet_peer_queue_outgoing_command(), enet_peer_setup_outgoing_command(), ENET_PEER_STATE_CONNECTED, ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE, ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED, ENET_PROTOCOL_COMMAND_SEND_FRAGMENT, ENET_PROTOCOL_COMMAND_SEND_RELIABLE, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE_FRAGMENT, ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED, ENET_PROTOCOL_MAXIMUM_FRAGMENT_COUNT, _ENetProtocolSendFragment::fragmentCount, _ENetProtocolSendFragment::fragmentNumber, _ENetProtocolSendFragment::fragmentOffset, _ENetProtocol::header, _ENetProtocol::sendFragment, _ENetProtocol::sendReliable, _ENetProtocol::sendUnreliable, _ENetProtocol::sendUnsequenced, _ENetProtocolSendFragment::startSequenceNumber, and _ENetProtocolSendFragment::totalLength.
Referenced by enet_host_broadcast().
void enet_peer_setup_outgoing_command | ( | ENetPeer * | peer, |
ENetOutgoingCommand * | outgoingCommand | ||
) |
#include <peer.c>
References _ENetOutgoingCommand::command, ENET_HOST_TO_NET_16, enet_list_end, enet_list_insert(), ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE, ENET_PROTOCOL_COMMAND_FLAG_UNSEQUENCED, ENET_PROTOCOL_COMMAND_MASK, ENET_PROTOCOL_COMMAND_SEND_UNRELIABLE, ENET_PROTOCOL_COMMAND_SEND_UNSEQUENCED, enet_protocol_command_size(), _ENetOutgoingCommand::reliableSequenceNumber, and _ENetOutgoingCommand::unreliableSequenceNumber.
Referenced by enet_peer_queue_outgoing_command(), and enet_peer_send().
int enet_peer_throttle | ( | ENetPeer * | peer, |
enet_uint32 | rtt | ||
) |
#include <peer.c>
void enet_peer_throttle_configure | ( | ENetPeer * | peer, |
enet_uint32 | interval, | ||
enet_uint32 | acceleration, | ||
enet_uint32 | deceleration | ||
) |
#include <peer.c>
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. The lowest mean round trip time from the sending of a reliable packet to the receipt of its acknowledgement is measured over an amount of time specified by the interval parameter in milliseconds. If a measured round trip time happens to be significantly less than the mean round trip time measured over the interval, then the throttle probability is increased to allow more traffic by an amount specified in the acceleration parameter, which is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE constant. If a measured round trip time happens to be significantly greater than the mean round trip time measured over the interval, then the throttle probability is decreased to limit traffic by an amount specified in the deceleration parameter, which is a ratio to the ENET_PEER_PACKET_THROTTLE_SCALE constant. When the throttle has a value of ENET_PEER_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 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.
peer | peer to configure |
interval | interval, in milliseconds, over which to measure lowest mean RTT; the default value is ENET_PEER_PACKET_THROTTLE_INTERVAL. |
acceleration | rate at which to increase the throttle probability as mean RTT declines |
deceleration | rate at which to decrease the throttle probability as mean RTT increases |
References _ENetProtocolCommandHeader::channelID, _ENetProtocolCommandHeader::command, ENET_HOST_TO_NET_32, enet_peer_queue_outgoing_command(), ENET_PROTOCOL_COMMAND_FLAG_ACKNOWLEDGE, ENET_PROTOCOL_COMMAND_THROTTLE_CONFIGURE, _ENetProtocol::header, _ENetProtocolThrottleConfigure::packetThrottleAcceleration, _ENetProtocolThrottleConfigure::packetThrottleDeceleration, _ENetProtocolThrottleConfigure::packetThrottleInterval, and _ENetProtocol::throttleConfigure.
void enet_peer_timeout | ( | ENetPeer * | peer, |
enet_uint32 | timeoutLimit, | ||
enet_uint32 | timeoutMinimum, | ||
enet_uint32 | timeoutMaximum | ||
) |
#include <peer.c>
Sets the timeout parameters for a peer.
The timeout parameter control how and when a peer will timeout from a failure to acknowledge reliable traffic. Timeout values use an exponential backoff mechanism, where if a reliable packet is not acknowledge within some multiple of the average RTT plus a variance tolerance, the timeout will be doubled until it reaches a set limit. If the timeout is thus at this limit and reliable packets have been sent but not acknowledged within a certain minimum time period, the peer will be disconnected. Alternatively, if reliable packets have been sent but not acknowledged for a certain maximum time period, the peer will be disconnected regardless of the current timeout limit value.
peer | the peer to adjust |
timeoutLimit | the timeout limit; defaults to ENET_PEER_TIMEOUT_LIMIT if 0 |
timeoutMinimum | the timeout minimum; defaults to ENET_PEER_TIMEOUT_MINIMUM if 0 |
timeoutMaximum | the timeout maximum; defaults to ENET_PEER_TIMEOUT_MAXIMUM if 0 |
References ENET_PEER_TIMEOUT_LIMIT, ENET_PEER_TIMEOUT_MAXIMUM, and ENET_PEER_TIMEOUT_MINIMUM.