29 class ServerStatusChangedCallback;
31 class MessageAggregatedBlob;
32 class MessageBlobHandler;
33 class BlobFieldsStore;
41 class VisualDebugAttributesManager;
50 static KyUInt32 DefaultServerPort() {
return 4888; }
51 static KyUInt32 DefaultBroadcastPort() {
return 4887; }
104 void UseNavigationLab(
KyUInt32 serverPort = DefaultServerPort(),
KyUInt32 broadcastPort = DefaultBroadcastPort(), MessageReceiverRegistry* navigationLabCommandHandlers =
nullptr)
114 void UseLocalFile(
const char* localFileName,
FileOpenerBase* localFileOpener =
nullptr)
125 void SetWaitOnStart(
WaitOnStart waitOnStart) { m_waitOnStart = waitOnStart; }
138 void SetServerName(
const char* serverName) {
m_serverName = String(serverName); }
195 #if defined(KY_CONFIG_RELEASE) || !defined(KY_ENABLE_SOCKETS)
196 # define KY_DISABLE_VISUALDEBUGSERVER
199 #ifndef KY_DISABLE_VISUALDEBUGSERVER
218 class VisualDebugServer
231 bool IsStarted()
const {
return m_isStarted; }
234 bool IsReadyToSend() {
return m_isReadyToSend && IsConnectionEstablished(); }
240 void SendStats(
const FloatStat& timeStat,
const char* groupName);
241 void SendStats(
const char* statName,
const FloatStat& timeStat,
const char* groupName);
246 void SendUInt32(
const char* statName,
const KyUInt32 value,
const char* groupName);
247 void SendInt32(
const char* statName,
const KyInt32 value,
const char* groupName);
248 void SendFloat32(
const char* statName,
const KyFloat32 value,
const char* groupName);
249 void SendString(
const char* statName,
const char* value,
const char* groupName);
253 void SendGameCamera(
const Vec3f& cameraPos,
const Vec3f& cameraLookAtPos,
const Vec3f& cameraUp,
KyFloat32 fovInDegrees);
254 void SendGameCameraAttitude(
const Vec3f& cameraPos,
const Vec3f& cameraRight,
const Vec3f& cameraUp,
const Vec3f& cameraFront,
KyFloat32 fovInDegrees);
258 void PauseMessageProcessing() { m_messageProcessingIsPaused =
true; }
259 void ResumeMessageProcessing() { m_messageProcessingIsPaused =
false; }
262 KyResult OpenNavigationLabConnection();
265 KyResult AggregateMessage(Ptr<BaseBlobHandler> handlerPtr);
269 KyResult SetupMessageRegistry(MessageReceiverRegistry* receiverRegistry, VisualDebugUnknownBlobTypeHandling unknownBlobTypeHandling = VisualDebugUnknownBlobTypeHandling::Log);
273 void ClearStatistics();
274 void SendInternalStatistics();
276 void SendStatGroups();
277 VisualDebugStatGroup* GetStatGroup(
const char* groupName);
278 VisualDebugStatGroup* GetOrCreateStatGroup(
const char* groupName);
281 void OnDisconnection();
282 void MakeReadyToSend();
284 KyResult OnConnectionUnsafeCallback();
285 KyResult OnDisconnectionUnsafeCallback();
287 void UpdateThreadMgr(
bool& out_needToWait);
292 void InitAttributesManager();
293 void CreateProfilingAttributes();
294 void CreateAdvancedProfilingAttributes();
295 void UpdateProfilingAttributes();
296 void UpdateAdvancedProfilingAttributes();
299 void EnableSynchronization(
bool enabled) { m_synchronizationEnabled = enabled; }
311 ~VisualDebugServer();
313 KyResult Start(
const VisualDebugServerConfig& config);
314 KyResult ReStart() {
return Start(m_config); }
319 static KyUInt32 GetInfiniteWaitDelay() {
return KY_WAIT_INFINITE; }
322 bool WaitWhileEstablishingConnection(
KyUInt32 maxDelayMilliseconds);
331 void SetSimulationTime(
KyFloat32 simulationTimeInSeconds) { m_simulationTimeInSeconds = simulationTimeInSeconds; }
336 KyResult Send(BaseBlobBuilder<T>& blobBuilder)
338 const KyUInt32 blobType = T::GetBlobTypeId();
339 Ptr<BaseBlobHandler> blobHandler = m_handlerRegistry.Get(blobType);
340 if (blobHandler ==
nullptr)
342 blobHandler = *KY_NEW BlobHandler<T>;
343 m_handlerRegistry.SetVal(blobType, blobHandler);
346 blobBuilder.Build((BlobHandler<T>&)*blobHandler);
347 return this->AggregateMessage(blobHandler);
354 KyResult Send(BaseBlobHandler& blobHandler);
361 KyResult SendLog(Kaim::LogMessageId messageId,
const char* message);
364 KyResult HandleAllReceivedMessages();
367 KyResult HandleNextReceivedMessage();
370 Ptr<Net::AMP::Message> GetNextReceivedMessage();
373 KyResult HandleMessage(Ptr<Net::AMP::Message> msg);
376 void SetAdvancedInternalStatistics(
bool enable) { m_enableAdvancedInternalStatistics = enable; }
379 void SetThreadId(ThreadId threadId) { m_operatingThreadId = threadId; }
382 ThreadId GetThreadId()
const {
return m_operatingThreadId; }
385 bool CanSafelyOperate()
const {
return (m_operatingThreadId == GetCurrentThreadId()); }
389 bool IsConnectionEstablished()
const;
392 bool IsSynchronizing() {
return (m_isReadyToSend ==
false && IsConnectionEstablished() ==
true); }
395 void WaitForEmptiedSendQueue();
398 void EndOfSynchronizationMessageReceived() { m_endOfSynchronizationMessageReceived =
true; }
400 Net::AMP::ThreadMgr* GetThreadMgr() {
return m_socketThreadMgr.GetPtr(); }
401 const Net::AMP::ThreadMgr* GetThreadMgr()
const {
return m_socketThreadMgr.GetPtr(); }
404 MemoryHeap* GetHeap() {
return Memory::GetHeapByAddress(m_socketThreadMgr.GetPtr()); }
407 const VisualDebugServerConfig* GetConfig()
const {
return &m_config; }
409 UserBlobRegistry<IDisplayListBuilder>* GetDisplayListBuilderRegistry() {
return m_displayListBuilderRegistry; }
413 KY_DEPRECATED(
bool IsConnected()) {
return IsReadyToSend(); }
417 VisualDebugServerConfig m_config;
420 Profiler* m_gameFrameTimeProfiler;
421 bool m_synchronizationEnabled;
425 bool m_isConnectionEstablished;
426 bool m_endOfSynchronizationMessageReceived;
427 bool m_isReadyToSend;
428 bool m_wasDisconnected;
429 ThreadId m_operatingThreadId;
432 Ptr<Net::AMP::ThreadMgr> m_socketThreadMgr;
433 Ptr<Net::AMP::DiscardMessageHandler> m_msgDiscarder;
434 Ptr<MessageBlobHandler> m_msgBlobHandler;
435 SocketDispatcherFactory* m_socketFactory;
438 friend class ServerStatusChangedCallback;
439 Ptr<ServerStatusChangedCallback> m_statusCallback;
440 Event m_connectedEvent;
443 typedef UserPtrBlobRegistry<BaseBlobHandler> BlobHandlerRegistry;
444 BlobHandlerRegistry m_handlerRegistry;
445 MessageAggregatedBlob* m_aggregatedBlobMsg;
448 List<Net::AMP::Message> m_msgList;
459 KyUInt32 m_receivedMessageCountInFrame;
461 UserBlobRegistry<SentBlobTypeStats> m_sentBlobTypeStatsRegistry;
463 KyArray<VisualDebugStatGroup> m_statGroups;
464 bool m_enableAdvancedInternalStatistics;
466 VisualDebugAttributesManager* m_visualDebugAttributesManager;
467 VisualDebugAttributeGroup* m_profilingVisualDebug;
468 VisualDebugAttributeGroup* m_advancedProfilingVisualDebug;
470 bool m_messageProcessingIsPaused;
473 Ptr<UserBlobRegistry<IDisplayListBuilder> > m_displayListBuilderRegistry;
487 class VisualDebugServer :
public DisabledVisualDebugServer
DisconnectionMode
Define how to detect disconnections.
Definition: visualdebugserver.h:67
Base interface for a class that opens a file on disk.
Definition: fileopener.h:30
DisconnectionMode m_disconnectionMode
Define how to detect disconnections.
Definition: visualdebugserver.h:180
const char * m_localFileName
mandatory if m_mode = Mode_UseLocalFile.
Definition: visualdebugserver.h:162
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
use socket errors to detect disconnections (recommended)
Definition: visualdebugserver.h:68
KyUInt32 m_expectedKiloBytesPerFrame
Specifies the expected amount of memory to allocate per frame. Used to define size of a message...
Definition: visualdebugserver.h:175
String m_serverName
Associate a name to the server to ease identification of this server when connecting from the Navigat...
Definition: visualdebugserver.h:186
Writes all visual debug information to a file on the platform.
Definition: visualdebugserver.h:57
KyInt32 m_localFileMegaBytesLimit
The size limit of the local file, when this limit is reached, the VisualDebugServer disconnects...
Definition: visualdebugserver.h:168
Mode m_mode
The visual debug information destination mode.
Definition: visualdebugserver.h:142
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
KyUInt32 m_maximumMegaBytes
Specifies the maximum amount of memory this VisualDebugServer is allowed to allocate for creating mes...
Definition: visualdebugserver.h:173
void SetMemoryConsumption(KyUInt32 expectedKiloBytesPerFrame, KyUInt32 maximumMegaBytesToUse)
Define memory limitations for the VisualDebugServer.
Definition: visualdebugserver.h:128
std::uint32_t UInt32
uint32_t
Definition: SF_Types.h:137
Configure the VisualDebugServer.
Definition: visualdebugserver.h:46
#define KY_DEPRECATED(expr)
The compiler issues a warning when a deprecated function or typedef is used.
Definition: types.h:93
Navigation return code class.
Definition: types.h:108
KyUInt32 m_broadcastPort
The port used to broadcast the existence of this server.
Definition: visualdebugserver.h:150
RunMode
Determine how the data are sent.
Definition: visualdebugserver.h:73
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
run in current thread (recommended for most platforms)
Definition: visualdebugserver.h:74
Sends visual debug information to the NavigationLab over the Network.
Definition: visualdebugserver.h:56
KyUInt32 m_serverPort
The port used to listen to NavigationLab incoming connections.
Definition: visualdebugserver.h:147
use secondary threads for sending blobs
Definition: visualdebugserver.h:75
std::int32_t KyInt32
int32_t
Definition: types.h:24
FileOpenerBase * m_localFileOpener
if m_localFileOpener is NULL, DefaultFileOpener will be used
Definition: visualdebugserver.h:165
void UseNavigationLab(KyUInt32 serverPort=DefaultServerPort(), KyUInt32 broadcastPort=DefaultBroadcastPort(), MessageReceiverRegistry *navigationLabCommandHandlers=nullptr)
Reduce chances of selecting conflicting ports by looking at :
Definition: visualdebugserver.h:104
MessageReceiverRegistry * m_navigationLabCommandHandlers
Optional, handles the commands that come from the Autodesk Navigation from the Network.
Definition: visualdebugserver.h:157
Mode
Enumerates the visual debug information destination.
Definition: visualdebugserver.h:55
Start will block until a connection occurs.
Definition: visualdebugserver.h:63
#define KyUInt32MAXVAL
KyUInt32 max value
Definition: types.h:68
RunMode m_runMode
Define how to run the server, either directly in the current thread (recommended), or using secondary threads.
Definition: visualdebugserver.h:183
Start won't wait for a connection.
Definition: visualdebugserver.h:62
float KyFloat32
float
Definition: types.h:32
use heartbeat messages to detect disconnections (disconnection can occur when breakpointing) ...
Definition: visualdebugserver.h:69
WaitOnStart
Define the behavior for VisualDebugServer::Start.
Definition: visualdebugserver.h:61