Open 3D Engine AzNetworking API Reference  2305.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AzNetworking::UdpConnection Class Reference

Connection class for udp endpoints. More...

#include <UdpConnection.h>

Inherits AzNetworking::IConnection.

Public Member Functions

 UdpConnection (ConnectionId connectionId, const IpAddress &remoteAddress, UdpNetworkInterface &networkInterface, ConnectionRole connectionRole)
 
DtlsEndpoint::ConnectResult ProcessHandshakeData (const UdpPacketEncodingBuffer &dtlsData)
 
void UpdateHeartbeat (AZ::TimeMs currentTimeMs)
 
DtlsEndpointGetDtlsEndpoint ()
 
const UdpPacketTrackerGetPacketTracker () const
 
UdpPacketTrackerGetPacketTracker ()
 
uint32_t GetReliableQueueSize () const
 
void ProcessAcked (PacketId packetId, AZ::TimeMs currentTimeMs)
 
void SetTimeoutId (TimeoutId timeoutId)
 
TimeoutId GetTimeoutId () const
 
bool SendReliablePacket (const IPacket &packet) override
 IConnection interface.
 
PacketId SendUnreliablePacket (const IPacket &packet) override
 
bool WasPacketAcked (PacketId packetId) const override
 
ConnectionState GetConnectionState () const override
 
ConnectionRole GetConnectionRole () const override
 
bool Disconnect (DisconnectReason reason, TerminationEndpoint endpoint) override
 
void SetConnectionMtu (uint32_t connectionMtu) override
 
uint32_t GetConnectionMtu () const override
 
- Public Member Functions inherited from AzNetworking::IConnection
 IConnection (ConnectionId connectionId, const IpAddress &address)
 
ConnectionId GetConnectionId () const
 
void SetUserData (void *userData)
 
void * GetUserData () const
 
void SetRemoteAddress (const IpAddress &address)
 
const IpAddressGetRemoteAddress () const
 
const ConnectionMetricsGetMetrics () const
 
ConnectionMetricsGetMetrics ()
 
const ConnectionQualityGetConnectionQuality () const
 
ConnectionQualityGetConnectionQuality ()
 

Protected Member Functions

bool PrepareReliablePacketForSend (PacketId packetId, SequenceId reliableSequenceId, const IPacket &packet)
 
void ProcessSent (PacketId packetId, const IPacket &packet, uint32_t packetSize, ReliabilityType reliability)
 
PacketTimeoutResult ProcessTimeout (PacketId packetId, ReliabilityType reliability)
 
bool ProcessReceived (UdpPacketHeader &header, const NetworkOutputSerializer &serializer, uint32_t packetSize, AZ::TimeMs currentTimeMs)
 
PacketDispatchResult HandleCorePacket (IConnectionListener &listener, UdpPacketHeader &header, ISerializer &serializer)
 
 AZ_DISABLE_COPY_MOVE (UdpConnection)
 

Protected Attributes

UdpNetworkInterfacem_networkInterface
 
UdpPacketTracker m_packetTracker
 
UdpReliableQueue m_reliableQueue
 
UdpFragmentQueue m_fragmentQueue
 
ConnectionState m_state = ConnectionState::Disconnected
 
ConnectionRole m_connectionRole = ConnectionRole::Connector
 
DtlsEndpoint m_dtlsEndpoint
 
AZ::TimeMs m_lastSentPacketMs
 
uint32_t m_unackedPacketCount = 0
 
uint32_t m_connectionMtu = MaxUdpTransmissionUnit
 
TimeoutId m_timeoutId
 
uint32_t m_timeoutCounter = 0
 

Friends

class UdpFragmentQueue
 
class UdpNetworkInterface
 

Detailed Description

Connection class for udp endpoints.

Constructor & Destructor Documentation

AzNetworking::UdpConnection::UdpConnection ( ConnectionId  connectionId,
const IpAddress remoteAddress,
UdpNetworkInterface networkInterface,
ConnectionRole  connectionRole 
)

Constructor

Parameters
connectionIdthe connection identifier to use for this connection
remoteAddressthe remote address this connection
networkInterfacereference of the network interface that owns this connection instance
connectionRolewhether this connection was the connector or acceptor

Member Function Documentation

bool AzNetworking::UdpConnection::Disconnect ( DisconnectReason  reason,
TerminationEndpoint  endpoint 
)
overridevirtual

Disconnects the connection with the provided termination reason

Parameters
reasonreason for the disconnect
endpointwhich endpoint initiated the disconnect, local or remote
Returns
boolean true on success

Implements AzNetworking::IConnection.

uint32_t AzNetworking::UdpConnection::GetConnectionMtu ( ) const
overridevirtual

Returns the connection maximum transmission unit. Currently unsupported on TcpConnections

Returns
the max transmission unit for this connection

Implements AzNetworking::IConnection.

ConnectionRole AzNetworking::UdpConnection::GetConnectionRole ( ) const
overridevirtual

Retrieves the connection role of this connection instance, whether it was initiated or accepted.

Returns
whether this connection was initiated or accepted

Implements AzNetworking::IConnection.

ConnectionState AzNetworking::UdpConnection::GetConnectionState ( ) const
overridevirtual

Retrieves the connection state for this IConnection instance.

Returns
the current connection state for this IConnection instance

Implements AzNetworking::IConnection.

DtlsEndpoint & AzNetworking::UdpConnection::GetDtlsEndpoint ( )
inline

Returns a suitable encryption endpoint for this connection type.

Returns
reference to the connections encryption endpoint
const UdpPacketTracker & AzNetworking::UdpConnection::GetPacketTracker ( ) const
inline

Retrieves packet delivery tracker instance for the specified connection.

Returns
reference to the requested packet tracker instance
UdpPacketTracker & AzNetworking::UdpConnection::GetPacketTracker ( )
inline

Retrieves packet delivery tracker instance for the specified connection.

Returns
reference to the requested packet tracker instance
uint32_t AzNetworking::UdpConnection::GetReliableQueueSize ( ) const
inline

Returns the number of unacked reliable messages still pending in the reliable queue.

Returns
the number of unacked reliable messages still pending in the reliable queue
TimeoutId AzNetworking::UdpConnection::GetTimeoutId ( ) const
inline

Retrieves the timeout identifier for this connection instance.

Returns
the timeout identifier for this connection instance
PacketDispatchResult AzNetworking::UdpConnection::HandleCorePacket ( IConnectionListener listener,
UdpPacketHeader header,
ISerializer serializer 
)
protected

Handle a core network packet.

Parameters
listenera connection listener to receive connection related events
headerthe packet header received to process
serializerthe output serializer containing the transmitted packet data
Returns
PacketDispatchResult result of processing the core packet
bool AzNetworking::UdpConnection::PrepareReliablePacketForSend ( PacketId  packetId,
SequenceId  reliableSequenceId,
const IPacket packet 
)
inlineprotected

Prepare a reliable packet for transmission.

Parameters
packetIdidentifier of the packet being sent
packetreference to the packet being transmitted
Returns
boolean true on success, false on failure
void AzNetworking::UdpConnection::ProcessAcked ( PacketId  packetId,
AZ::TimeMs  currentTimeMs 
)

Acks a packetId.

Parameters
packetIdthe PacketId of the packet being acked
currentTimeMscurrent wall clock time in milliseconds
DtlsEndpoint::ConnectResult AzNetworking::UdpConnection::ProcessHandshakeData ( const UdpPacketEncodingBuffer dtlsData)

Helper to exchange dtls handshake data during connection handshake

Parameters
dtlsDatadata buffer containing dtls handshake packet
Returns
the current result code for the dtls handshake operation, failed, pending, or complete
bool AzNetworking::UdpConnection::ProcessReceived ( UdpPacketHeader header,
const NetworkOutputSerializer serializer,
uint32_t  packetSize,
AZ::TimeMs  currentTimeMs 
)
protected

Process a received packet header.

Parameters
headerthe packet header received to process
serializerthe output serializer containing the transmitted packet data
packetSizethe size of the received packet in bytes
currentTimeMscurrent wall clock time in milliseconds
Returns
boolean true on successful handling of the received header
void AzNetworking::UdpConnection::ProcessSent ( PacketId  packetId,
const IPacket packet,
uint32_t  packetSize,
ReliabilityType  reliability 
)
protected

Process a packet for sending.

Parameters
packetIdidentifier of the packet being sent
packetreference to the packet being transmitted
packetSizepacket size in bytes
reliabilitywhether or not to guarantee delivery
PacketTimeoutResult AzNetworking::UdpConnection::ProcessTimeout ( PacketId  packetId,
ReliabilityType  reliability 
)
protected

Process a timed out packet header.

Parameters
packetIdidentifier of the packet that timed out
reliabilitywhether or not the packet that timed out was marked reliable
Returns
PacketTimeoutResult::Acked if the packet was confirmed to be received prior to timeout, PacketTimeoutResult::Lost if not
PacketId AzNetworking::UdpConnection::SendUnreliablePacket ( const IPacket packet)
overridevirtual

A helper function that transmits a packet on this connection unreliably.

Parameters
packetpacket to transmit
Returns
the unreliable packet identifier of the transmitted packet

Implements AzNetworking::IConnection.

void AzNetworking::UdpConnection::SetConnectionMtu ( uint32_t  connectionMtu)
overridevirtual

Sets connection maximum transmission unit for this connection. Currently unsupported on TcpConnections

Parameters
connectionMtuthe max transmission unit for this connection

Implements AzNetworking::IConnection.

void AzNetworking::UdpConnection::SetTimeoutId ( TimeoutId  timeoutId)
inline

Sets the timeout identifier for this connection instance.

Parameters
timeoutIdthe timeoutId to use for this connection instance
void AzNetworking::UdpConnection::UpdateHeartbeat ( AZ::TimeMs  currentTimeMs)

Updates the connection heartbeat if active.

Parameters
currentTimeMscurrent wall clock time in milliseconds
bool AzNetworking::UdpConnection::WasPacketAcked ( PacketId  packetId) const
overridevirtual

Returns true if the given packet id was confirmed acknowledged by the remote endpoint, false otherwise.

Parameters
packetIdthe packet id of the packet to confirm acknowledgment of
Returns
boolean true if the packet is confirmed acknowledged, false if the packet number is out of range, lost, or still pending acknowledgment

Implements AzNetworking::IConnection.


The documentation for this class was generated from the following files: