Open 3D Engine AzFramework 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.
AzFramework::AssetSystem::AssetProcessorConnection Class Reference

#include <AssetProcessorConnection.h>

Inherits AzFramework::SocketConnection.

Public Member Functions

 AZ_RTTI (AssetProcessorConnection, "{C205009B-74EF-4C47-8623-917883756330}", SocketConnection)
 
bool Connect (const char *address, AZ::u16 port) override
 disconnects any current connection and starts to reconnect
 
bool Disconnect (bool completeDisconnect=false) override
 
bool Listen (AZ::u16 port) override
 disconnects any current connection and starts to listen for a connection
 
EConnectionState GetConnectionState () const override
 Get the current connection state.
 
bool IsConnected () const override
 
bool IsDisconnected () const override
 
bool SendMsg (AZ::u32 typeId, const void *dataBuffer, AZ::u32 dataLength) override
 Send a message across the connection by message id.
 
bool SendMsg (AZ::u32 typeId, AZ::u32 serial, const void *dataBuffer, AZ::u32 dataLength) override
 Send a message across the connection by message id.
 
bool SendRequest (AZ::u32 typeId, const void *dataBuffer, AZ::u32 dataLength, TMessageCallback handler) override
 Send a message and wait for the response.
 
SocketConnection::TMessageCallbackHandle AddMessageHandler (AZ::u32 typeId, TMessageCallback callback) override
 
void RemoveMessageHandler (AZ::u32 typeId, TMessageCallbackHandle callbackHandle) override
 Remove callback for specific typeId (allows multiple callbacks per id)
 
AZ::s32 GetLastResult () const override
 Get the last socket result code from any socket call.
 
AZStd::string GetLastErrorMessage () const override
 Get the last socket-related error from any socket call.
 
bool NegotiationFailed ()
 
void Configure (const char *branchToken, const char *platform, const char *identifier, const char *projectName)
 
- Public Member Functions inherited from AzFramework::SocketConnection
 AZ_RTTI (SocketConnection, "{CF95282C-B514-4AB8-8C72-6063AD03725B}")
 
virtual bool Connect (const char *address, AZ::u16 port)=0
 
virtual bool Disconnect (bool completeDisconnect=false)=0
 
virtual bool Listen (AZ::u16 port)=0
 
virtual EConnectionState GetConnectionState () const =0
 Get the current connection state.
 
virtual bool IsConnected () const =0
 
virtual bool IsDisconnected () const =0
 
virtual bool SendMsg (AZ::u32 typeId, const void *dataBuffer, AZ::u32 dataLength)=0
 Send a message across the connection by message id.
 
virtual bool SendMsg (AZ::u32 typeId, AZ::u32 serial, const void *dataBuffer, AZ::u32 dataLength)=0
 Send a message across the connection by message id.
 
virtual bool SendRequest (AZ::u32 typeId, const void *dataBuffer, AZ::u32 dataLength, TMessageCallback handler)=0
 Send a message and wait for the response.
 
virtual TMessageCallbackHandle AddMessageHandler (AZ::u32 typeId, TMessageCallback callback)=0
 
virtual void RemoveMessageHandler (AZ::u32 typeId, TMessageCallbackHandle callbackHandle)=0
 Remove callback for specific typeId (allows multiple callbacks per id)
 
virtual AZ::s32 GetLastResult () const
 Get the last socket result code from any socket call.
 
virtual AZStd::string GetLastErrorMessage () const
 Get the last socket-related error from any socket call.
 

Public Attributes

bool m_unitTesting
 

Protected Member Functions

bool NegotiateWithServer ()
 
bool NegotiateWithClient ()
 
void StartThread (ThreadState &thread)
 
void JoinThread (ThreadState &thread, AZStd::condition_variable *wakeUpCondition=nullptr)
 
void StartSendRecvThreads ()
 
void JoinSendRecvThreads ()
 
void SendThread ()
 
void RecvThread ()
 
void ConnectThread ()
 
void DisconnectThread ()
 
void ListenThread ()
 
bool SendRequest (AZ::u32 typeId, AZ::u32 serial, const void *dataBuffer, AZ::u32 dataLength, TMessageCallback handler)
 
void QueueMessageForSend (AZ::u32 typeId, AZ::u32 serial, const void *dataBuffer, AZ::u32 dataLength)
 
void InvokeMessageHandler (AZ::u32 typeId, AZ::u32 serial, const void *dataBuffer, AZ::u32 dataLength)
 
void InvokeResponseHandler (AZ::u32 typeId, AZ::u32 serial, const void *dataBuffer, AZ::u32 dataLength)
 
void AddResponseHandler (AZ::u32 typeId, AZ::u32 serial, SocketConnection::TMessageCallback callback)
 
void RemoveResponseHandler (AZ::u32 typeId, AZ::u32 serial)
 
AZ::u32 GetNextSerial ()
 
SocketConnection::TMessageCallbackHandle GetNewCallbackHandle ()
 
void DebugMessage (const char *format,...)
 
void FlushResponseHandlers ()
 

Additional Inherited Members

- Public Types inherited from AzFramework::SocketConnection
enum class  EConnectionState {
  Connected , Connecting , Disconnected , Disconnecting ,
  Listening
}
 
typedef AZStd::function< void(AZ::u32, AZ::u32, const void *, AZ::u32)> TMessageCallback
 
typedef AZ::u32 TMessageCallbackHandle
 
- Static Public Member Functions inherited from AzFramework::SocketConnection
static SocketConnectionGetInstance ()
 Utility functions to get or set the one global instance of a SocketConnection.
 
static void SetInstance (SocketConnection *instance)
 
- Static Public Attributes inherited from AzFramework::SocketConnection
static const TMessageCallbackHandle s_invalidCallbackHandle = 0
 

Detailed Description

AssetProcessorConnection - an implementation of the SocketConnection interface using AzSocket It is primarily used for the AssetProcessor to connect to the game and stream files across the network

Member Function Documentation

◆ AddMessageHandler()

SocketConnection::TMessageCallbackHandle AzFramework::AssetSystem::AssetProcessorConnection::AddMessageHandler ( AZ::u32  typeId,
TMessageCallback  callback 
)
overridevirtual

Will call callback whenever a message of type typeId arrives.

Returns
returns a value that can be passed to /ref RemoveMessageHandler .

Implements AzFramework::SocketConnection.

◆ Connect()

bool AzFramework::AssetSystem::AssetProcessorConnection::Connect ( const char *  address,
AZ::u16  port 
)
overridevirtual

disconnects any current connection and starts to reconnect

Implements AzFramework::SocketConnection.

◆ Disconnect()

bool AzFramework::AssetSystem::AssetProcessorConnection::Disconnect ( bool  completeDisconnect = false)
overridevirtual

disconnects any current connection and stop any retrying to connect.

Parameters
completeDisconnectif true, guarantees that by the time Disconnect returns, we have disconnected and all threads are stopped.

Implements AzFramework::SocketConnection.

◆ GetConnectionState()

EConnectionState AzFramework::AssetSystem::AssetProcessorConnection::GetConnectionState ( ) const
overridevirtual

Get the current connection state.

Implements AzFramework::SocketConnection.

◆ GetLastErrorMessage()

AZStd::string AzFramework::AssetSystem::AssetProcessorConnection::GetLastErrorMessage ( ) const
overridevirtual

Get the last socket-related error from any socket call.

Reimplemented from AzFramework::SocketConnection.

◆ GetLastResult()

AZ::s32 AzFramework::AssetSystem::AssetProcessorConnection::GetLastResult ( ) const
overridevirtual

Get the last socket result code from any socket call.

Reimplemented from AzFramework::SocketConnection.

◆ IsConnected()

bool AzFramework::AssetSystem::AssetProcessorConnection::IsConnected ( ) const
overridevirtual

◆ IsDisconnected()

bool AzFramework::AssetSystem::AssetProcessorConnection::IsDisconnected ( ) const
overridevirtual

◆ Listen()

bool AzFramework::AssetSystem::AssetProcessorConnection::Listen ( AZ::u16  port)
overridevirtual

disconnects any current connection and starts to listen for a connection

Implements AzFramework::SocketConnection.

◆ RemoveMessageHandler()

void AzFramework::AssetSystem::AssetProcessorConnection::RemoveMessageHandler ( AZ::u32  typeId,
TMessageCallbackHandle  callbackHandle 
)
overridevirtual

Remove callback for specific typeId (allows multiple callbacks per id)

Implements AzFramework::SocketConnection.

◆ SendMsg() [1/2]

bool AzFramework::AssetSystem::AssetProcessorConnection::SendMsg ( AZ::u32  typeId,
AZ::u32  serial,
const void *  dataBuffer,
AZ::u32  dataLength 
)
overridevirtual

Send a message across the connection by message id.

Implements AzFramework::SocketConnection.

◆ SendMsg() [2/2]

bool AzFramework::AssetSystem::AssetProcessorConnection::SendMsg ( AZ::u32  typeId,
const void *  dataBuffer,
AZ::u32  dataLength 
)
overridevirtual

Send a message across the connection by message id.

Implements AzFramework::SocketConnection.

◆ SendRequest()

bool AzFramework::AssetSystem::AssetProcessorConnection::SendRequest ( AZ::u32  typeId,
const void *  dataBuffer,
AZ::u32  dataLength,
TMessageCallback  handler 
)
overridevirtual

Send a message and wait for the response.

Implements AzFramework::SocketConnection.


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