Open 3D Engine AzNetworking API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
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, uint16_t localPort=0)=0
 
virtual void Update ()=0
 Updates the INetworkInterface.
 
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 ()
 
virtual bool IsEncrypted () const =0
 
virtual bool IsOpen () const =0
 

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,
uint16_t  localPort = 0 
)
pure virtual

Opens a new connection to the provided address.

Parameters
remoteAddressthe IpAddress of the remote process to open a connection to
localPortthe local port number to open a socket on to initiate the connection, 0 binds to any available port
Returns
the connectionId of the new connection, or InvalidConnectionId if the operation failed

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

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ GetMetrics() [1/2]

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

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

Returns
reference to the metrics tracked by this network interface

◆ GetMetrics() [2/2]

const 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ IsEncrypted()

virtual bool AzNetworking::INetworkInterface::IsEncrypted ( ) const
pure virtual

Returns true if communications on this network interface are encrypted, false if not.

Returns
boolean true if communciations are encrypted, false if not

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

◆ IsOpen()

virtual bool AzNetworking::INetworkInterface::IsOpen ( ) const
pure virtual

Returns true if this connection instance is in an open state, and is capable of actively sending and receiving packets.

Returns
boolean true if this connection instance is in an open state

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

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.

◆ Update()

virtual void AzNetworking::INetworkInterface::Update ( )
pure virtual

◆ 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::TcpNetworkInterface, and AzNetworking::UdpNetworkInterface.


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