Open 3D Engine AzNetworking API Reference  2205.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
Public Member Functions | List of all members
AzNetworking::INetworkInterface Class Referenceabstract

Network interface class to abstract client/server and protocol concerns from application code. More...

#include <INetworkInterface.h>

Inherited by AzNetworking::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

Public Member Functions

 AZ_RTTI (INetworkInterface, "{ECDA6FA2-4AA0-435E-881F-214C4B179A31}")
 
virtual AZ::Name GetName () const =0
 
virtual ProtocolType GetType () const =0
 
virtual TrustZone GetTrustZone () const =0
 
virtual uint16_t GetPort () const =0
 
virtual IConnectionSetGetConnectionSet ()=0
 
virtual IConnectionListenerGetConnectionListener ()=0
 
virtual bool Listen (uint16_t port)=0
 
virtual ConnectionId Connect (const IpAddress &remoteAddress)=0
 
virtual void Update (AZ::TimeMs deltaTimeMs)=0
 
virtual bool SendReliablePacket (ConnectionId connectionId, const IPacket &packet)=0
 
virtual PacketId SendUnreliablePacket (ConnectionId connectionId, const IPacket &packet)=0
 
virtual bool WasPacketAcked (ConnectionId connectionId, PacketId packetId)=0
 
virtual bool StopListening ()=0
 
virtual bool Disconnect (ConnectionId connectionId, DisconnectReason reason)=0
 
virtual void SetTimeoutMs (AZ::TimeMs timeoutMs)=0
 
virtual AZ::TimeMs GetTimeoutMs () const =0
 
const NetworkInterfaceMetricsGetMetrics () const
 
NetworkInterfaceMetricsGetMetrics ()
 

Detailed Description

Network interface class to abstract client/server and protocol concerns from application code.

INetworkInterface provides an abstract API capable of receiving and opening IConnection objects, sending IPacket objects with optional reliability, and determining the delivery status of packets that have been sent unreliably (delivery of reliable packets is guaranteed as long as the associated connection remains open). INetworkInterface must be provided an IConnectionListener instance that outlives the INetworkInterface itself. The INetworkInterface also creates and manages the IConnectionSet, which tracks all open connections bound to the interface. INetworkInterface also provides GetMetrics functions which can be used to fetch a struct detailing a variety of metrics relating to send and receive rates for both packets and bytes in addition to the effect of features on those rates (such as packet size reduction due to compression.)

Member Function Documentation

◆ Connect()

virtual ConnectionId AzNetworking::INetworkInterface::Connect ( const IpAddress remoteAddress)
pure virtual

Opens a new connection to the provided address.

Parameters
remoteAddressthe IpAddress of the remote process to open a connection to
Returns
the connectionId of the new connection, or InvalidConnectionId if the operation failed

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ Disconnect()

virtual bool AzNetworking::INetworkInterface::Disconnect ( ConnectionId  connectionId,
DisconnectReason  reason 
)
pure virtual

Disconnects the specified connection.

Parameters
connectionIdidentifier of the connection to terminate
reasonreason for the disconnect
Returns
boolean true on success

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetConnectionListener()

virtual IConnectionListener& AzNetworking::INetworkInterface::GetConnectionListener ( )
pure virtual

Returns a reference to the connection listener for this network interface.

Returns
reference to the connection listener for this network interface

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetConnectionSet()

virtual IConnectionSet& AzNetworking::INetworkInterface::GetConnectionSet ( )
pure virtual

Returns the connection set for this network interface.

Returns
the connection set for this network interface

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetMetrics() [1/2]

NetworkInterfaceMetrics& AzNetworking::INetworkInterface::GetMetrics ( )

Non-const access to the metrics tracked by this network interface.

Returns
reference to the metrics tracked by this network interface

◆ GetMetrics() [2/2]

NetworkInterfaceMetrics & AzNetworking::INetworkInterface::GetMetrics ( ) const
inline

Const access to the metrics tracked by this network interface.

Returns
const reference to the metrics tracked by this network interface

◆ GetName()

virtual AZ::Name AzNetworking::INetworkInterface::GetName ( ) const
pure virtual

Retrieves the name of this network interface instance.

Returns
the name of this network interface instance

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetPort()

virtual uint16_t AzNetworking::INetworkInterface::GetPort ( ) const
pure virtual

Returns the port number this network interface is bound to.

Returns
the port number this network interface is bound to

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetTimeoutMs()

virtual AZ::TimeMs AzNetworking::INetworkInterface::GetTimeoutMs ( ) const
pure virtual

Retrieves the timeout time in milliseconds for this network interface, 0 ms means timeouts are disabled.

Returns
the timeout time in milliseconds for this network interface, 0 ms means timeouts are disabled

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetTrustZone()

virtual TrustZone AzNetworking::INetworkInterface::GetTrustZone ( ) const
pure virtual

Retrieves the trust zone for this network interface instance.

Returns
the trust zone for this network interface instance

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ GetType()

virtual ProtocolType AzNetworking::INetworkInterface::GetType ( ) const
pure virtual

Retrieves the type of this network interface instance.

Returns
the type of this network interface instance

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ Listen()

virtual bool AzNetworking::INetworkInterface::Listen ( uint16_t  port)
pure virtual

Opens the network interface to allow it to accept new incoming connections.

Parameters
portthe listen port number this network interface will potentially bind to, 0 if it's a don't care
Returns
boolean true if the operation was successful, false if it failed

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ SendReliablePacket()

virtual bool AzNetworking::INetworkInterface::SendReliablePacket ( ConnectionId  connectionId,
const IPacket packet 
)
pure virtual

A helper function that transmits a packet on this connection reliably. Note that a packetId is not returned here, since retransmits may cause the packetId to change

Parameters
connectionIdidentifier of the connection to send to
packetpacket to transmit
Returns
boolean true if the packet was transmitted (not an indication of delivery)

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ SendUnreliablePacket()

virtual PacketId AzNetworking::INetworkInterface::SendUnreliablePacket ( ConnectionId  connectionId,
const IPacket packet 
)
pure virtual

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

Parameters
connectionIdidentifier of the connection to send to
packetpacket to transmit
Returns
the unreliable packet identifier of the transmitted packet

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ SetTimeoutMs()

virtual void AzNetworking::INetworkInterface::SetTimeoutMs ( AZ::TimeMs  timeoutMs)
pure virtual

Sets the timeout time in milliseconds, 0 ms means timeouts are disabled.

Parameters
timeoutMsthe number of milliseconds with no traffic before we timeout and close a connection

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ StopListening()

virtual bool AzNetworking::INetworkInterface::StopListening ( )
pure virtual

Closes the network interface to stop accepting new incoming connections.

Returns
boolean true if the operation was successful, false if it failed

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ Update()

virtual void AzNetworking::INetworkInterface::Update ( AZ::TimeMs  deltaTimeMs)
pure virtual

Updates the INetworkInterface.

Parameters
deltaTimeMsmilliseconds since update was last invoked

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.

◆ WasPacketAcked()

virtual bool AzNetworking::INetworkInterface::WasPacketAcked ( ConnectionId  connectionId,
PacketId  packetId 
)
pure virtual

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

Parameters
connectionIdidentifier of the connection to send to
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

Implemented in AzNetworking::UdpNetworkInterface, and AzNetworking::TcpNetworkInterface.


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