Kaim::VisualDebugServer Class Reference

Kaim::VisualDebugServer Class Reference

#include <visualdebugserver.h>

Class Description

The VisualDebugServer manages the sending of data to clients.

Each World maintains an instance of this class, accessible through its World::GetVisualDebugServer() and created on World::StartVisualDebug() call.

Call NewFrame() must be called at the beginning of each game frame in your game loop in order to get frames correctly rendered in the NavigationLab.

IsConnected() should be called to know when VisualDebugServer is ready for calling Send* functions to be sure not to do useless computations.

VisualDebugServer is considered ready, i.e. IsConnected returning true, after NewFrame() was called while the connection is established and the synchronization step ended.

With KY_BUILD_SHIPPING defined, this class is still present but replaced by a fully inlined emptied version.

+ Examples:

Server Status

void NewFrame ()
 
void NewFrame (KyUInt32 gameFrameIndex)
 
bool IsStarted () const
 
bool IsConnected ()
 

Send Statistics

Send the key-value with min, max, average values that will be displayed in the NavigationLab under the given group name with other key-values.

void SendStats (const char *statName, const KyFloat32 value, const KyFloat32 average, const KyFloat32 max, const KyFloat32 min, const char *groupName)
 
void SendStats (const FloatStat &timeStat, const char *groupName)
 
void SendStats (const char *statName, const FloatStat &timeStat, const char *groupName)
 

Send Single Value

Send a key-value pair that will be displayed in the NavigationLab under the given group name with other key-values.

void SendUInt32 (const char *statName, const KyUInt32 value, const char *groupName)
 
void SendInt32 (const char *statName, const KyInt32 value, const char *groupName)
 
void SendFloat32 (const char *statName, const KyFloat32 value, const char *groupName)
 
void SendString (const char *statName, const char *value, const char *groupName)
 

Send Game-Specific info

void SendGameCamera (const Vec3f &cameraPos, const Vec3f &cameraLookAtPos, const Vec3f &cameraUp, KyFloat32 fovInDegrees)
 
void SendGameCameraAttitude (const Vec3f &cameraPos, const Vec3f &cameraRight, const Vec3f &cameraUp, const Vec3f &cameraFront, KyFloat32 fovInDegrees)
 

Advanced usage : Handling Received Blob Messages

void PauseMessageProcessing ()
 
void ResumeMessageProcessing ()
 

For internal use only

These functions are used by internal components.

They are mainly used by World and WorldElement instances.

So there's no need for Navigation's users to call them directly

 VisualDebugServer ()
 
 ~VisualDebugServer ()
 
KyResult Start (const VisualDebugServerConfig &config)
 
KyResult ReStart ()
 
void Stop ()
 
bool WaitWhileEstablishingConnection (KyUInt32 maxDelayMilliseconds)
 
void Flush ()
 
void SetSimulationTime (KyFloat32 simulationTimeInSeconds)
 
template<class T >
KyResult Send (BaseBlobBuilder< T > &blobBuilder)
 
KyResult Send (BaseBlobHandler &blobHandler)
 
KyResult Send (IQuery *query)
 
KyResult HandleAllReceivedMessages ()
 
KyResult HandleNextReceivedMessage ()
 
Ptr< Net::AMP::Message > GetNextReceivedMessage ()
 
KyResult HandleMessage (Ptr< Net::AMP::Message > msg)
 
void SetAdvancedInternalStatistics (bool enable)
 
void SetThreadId (ThreadId threadId)
 
ThreadId GetThreadId () const
 
bool CanSafelyOperate () const
 
bool IsConnectionEstablished () const
 
bool IsSynchronizing ()
 
void WaitForEmptiedSendQueue ()
 
KyUInt32 GetFrameIndex () const
 
void OnSynchronizationDone ()
 
Net::AMP::ThreadMgr * GetThreadMgr ()
 
const Net::AMP::ThreadMgr * GetThreadMgr () const
 
MemoryHeap * GetHeap ()
 
const VisualDebugServerConfigGetConfig () const
 
UserBlobRegistry< IDisplayListBuilder > * GetDisplayListBuilderRegistry ()
 
static KyUInt32 GetInfiniteWaitDelay ()
 

Member Function Documentation

bool Kaim::VisualDebugServer::CanSafelyOperate ( ) const
inline

Check if it is safe to call Update and Send functions.

void Kaim::VisualDebugServer::Flush ( )

Effectively, send/write all messages (exactly they are passed to the OS).

KyUInt32 Kaim::VisualDebugServer::GetFrameIndex ( ) const
inline

Retrieves the number of the current frame.

MemoryHeap* Kaim::VisualDebugServer::GetHeap ( )
inline
Returns
The MemoryHeap used for sending messages.
static KyUInt32 Kaim::VisualDebugServer::GetInfiniteWaitDelay ( )
inlinestatic

Defines a special value that can be passed to VisualDebugServer::WaitWhileEstablishingConnection() in the calling thread until the connection is established.

Ptr<Net::AMP::Message> Kaim::VisualDebugServer::GetNextReceivedMessage ( )

Return next received message.

ThreadId Kaim::VisualDebugServer::GetThreadId ( ) const
inline

Get the ThreadId that Send and Update are supposed to be called from.

Net::AMP::ThreadMgr* Kaim::VisualDebugServer::GetThreadMgr ( )
inline

Accessor to the internal ThreadMgr.

const Net::AMP::ThreadMgr* Kaim::VisualDebugServer::GetThreadMgr ( ) const
inline

Accessor to the internal ThreadMgr.

KyResult Kaim::VisualDebugServer::HandleAllReceivedMessages ( )

Get and handle all received messages based on the MessageReceiverRegistry parameter provided to Start()

KyResult Kaim::VisualDebugServer::HandleMessage ( Ptr< Net::AMP::Message >  msg)

Handle the given message.

KyResult Kaim::VisualDebugServer::HandleNextReceivedMessage ( )
Returns
KY_SUCCESS if a message was handled, KY_ERROR if there's no message to handle.
bool Kaim::VisualDebugServer::IsConnected ( )
inline

Tells if it's worth calling the Send* functions.

+ Examples:
bool Kaim::VisualDebugServer::IsConnectionEstablished ( ) const

Indicates whether the ThreadManager has established a connection to a network socket or if the localFile can be written.

The connection being established doesn't mean the VisualDebugServer is ready to send information, cf. IsConnected()

bool Kaim::VisualDebugServer::IsStarted ( ) const
inline
Returns
true between Start and Stop calls, false otherwise.
bool Kaim::VisualDebugServer::IsSynchronizing ( )
inline

Tells if currently synchronizing, in this state Send should only be called to send synchronization data (typically the NavData to be used for debugging).

void Kaim::VisualDebugServer::NewFrame ( )

Indicates the beginning of a new game frame.

Auto-increment the frame index NOTE : NewFrame() must be called at the beginning of the Game frame so that a frame of VisualDebugServer mathces exactly a Game frame

+ Examples:
void Kaim::VisualDebugServer::NewFrame ( KyUInt32  gameFrameIndex)
inline

same as NewFrame() but force the frame index

template<class T >
KyResult Kaim::VisualDebugServer::Send ( BaseBlobBuilder< T > &  blobBuilder)
inline

Sends a blob from a BlobBuilder, the blob will be built into the message, no copy occurs.

This Send function should be favor over Send(BaseBlobHandler&) since the memory used to build the blobs is reused here

KyResult Kaim::VisualDebugServer::Send ( BaseBlobHandler &  blobHandler)

Sends a blob, the blob will be copied into a secondary buffer.

Send(BaseBlobBuilder<T>&) should be favor over this Send function since the memory used to build the blobs will be reused there.

Portion of code using this function when KY_BUILD_SHIPPING is defined should be guarded with #ifndef KY_BUILD_SHIPPING in order to save cpu and memory taken to build the blob in Shipping build.

void Kaim::VisualDebugServer::SetAdvancedInternalStatistics ( bool  enable)
inline

Enable additional statistics to be sent. These statistics are mainly useful for internal development/debugging.

void Kaim::VisualDebugServer::SetSimulationTime ( KyFloat32  simulationTimeInSeconds)
inline

Usually, set by Kaim::World with the given simulation time passed to Kaim::World::Update().

It can differ from the frame time computed in NewFrame(), so a VisualDebug replay can be played with the frame time or the simulation time.

By default, the NavigationLab will use the simulation time if it is provided instead of the frame time, because simulation time is usually a fix step which is better to use for debugging purposes.

void Kaim::VisualDebugServer::SetThreadId ( ThreadId  threadId)
inline

Set the ThreadId that Send and Update are supposed to be called from. By default, assigned when calling Start.

bool Kaim::VisualDebugServer::WaitWhileEstablishingConnection ( KyUInt32  maxDelayMilliseconds)

Wait for the connection to be established (pass GetInfiniteWaitDelay() to wait infinitely if no connection).


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