9 #ifndef Navigation_VisualDebugClient_H
10 #define Navigation_VisualDebugClient_H
17 #if defined(KY_BUILD_SHIPPING) || !defined(KY_ENABLE_SOCKETS) || !defined(KY_ENABLE_THREADS)
18 # define KY_DISABLE_VISUALDEBUGCLIENT
21 #ifndef KY_DISABLE_VISUALDEBUGCLIENT
41 class MessageAggregatedBlob;
42 class SocketDispatcherFactory;
43 class ClientStatusChangedCallback;
44 class AcknowledgeConnectionMessageReceiver;
46 class VisualDebugClientScopedFileWriter;
49 class MessagePortHandler;
60 class VisualDebugClient
105 {
return (m_socketThreadMgr ? m_socketThreadMgr->IsReceptionPipelineEmpty() :
true); }
115 if (m_socketThreadMgr)
117 blobBuilder.m_heap = GetHeap();
118 Ptr<BaseBlobHandler> blobHandler = *KY_HEAP_NEW(blobBuilder.m_heap)
BlobHandler<T>;
120 return this->CreateMessageAndSend(blobHandler);
129 KyResult Send(Kaim::BaseBlobHandler& blobHandler);
145 void ListenForAvailableServers();
146 void GetAvailableServers(
KyArray<Ptr<Net::AMP::MessagePort> >& availableServers);
147 void StopListeningForAvailableServers();
154 void SetupMessageRegistryForServerPorts(Net::AMP::MessageTypeRegistry& customMsgTypeRegistry);
155 void SetupMessageRegistryForBlobs(Net::AMP::MessageTypeRegistry& customMsgTypeRegistry);
156 void CreateManager(SocketDispatchMode mode, Net::AMP::MessageTypeRegistry& customMsgTypeRegistry,
bool initSocketConnection);
157 void DestroyManager();
161 KyResult CreateMessageAndSend(Ptr<BaseBlobHandler> handlerPtr);
163 KyResult SendMessage(MessageBlob* msg);
165 Ptr<Net::AMP::Message> CreateAndReadMessage(File& stream);
167 void HandleAllReceivedMessages();
168 void Handle(Ptr<Net::AMP::Message> msg);
171 Net::AMP::ThreadMgr* GetThreadMgr() {
return m_socketThreadMgr.GetPtr(); }
172 const Net::AMP::ThreadMgr* GetThreadMgr()
const {
return m_socketThreadMgr.GetPtr(); }
173 MemoryHeap* GetHeap() {
return Memory::GetHeapByAddress(m_socketThreadMgr.GetPtr()); }
175 void WaitForEmptiedSendQueue();
177 RunMode GetRunMode()
const {
return m_runMode; }
179 File* GetFile() {
return m_file; }
182 static const KyUInt32 NotConnected = 0;
183 Kaim::AtomicInt<KyUInt32> m_wasConnected;
184 bool m_isSynchronized;
186 KyArray<char> m_receiveBuffer;
188 Kaim::Ptr<Net::AMP::ThreadMgr> m_socketThreadMgr;
189 Kaim::Ptr<Net::AMP::DiscardMessageHandler> m_msgDiscarder;
190 Kaim::Ptr<MessagePortHandler> m_receivedMsgPort;
191 Kaim::Ptr<MessageBlobHandler> m_msgBlobHandler;
192 Kaim::Ptr<MessageAggregatedBlobHandler> m_msgAggregatedBlobHandler;
193 Kaim::SocketDispatcherFactory* m_socketFactory;
194 Kaim::Ptr<File> m_file;
197 friend class ClientStatusChangedCallback;
198 Kaim::Ptr<ClientStatusChangedCallback> m_statusCallback;
199 Kaim::Event m_connectedEvent;
206 class VisualDebugClientScopedFileWriter
210 VisualDebugClientScopedFileWriter();
211 ~VisualDebugClientScopedFileWriter();
218 KyResult WriteMessageToFile(Net::AMP::Message*& message);
222 void Init(VisualDebugClient* visualDebugClient, VisualDebugClient::RunMode runMode);
225 VisualDebugClient* m_visualDebugClient;
226 VisualDebugClient::RunMode m_runMode;
227 MessageAggregatedBlob* m_aggregatedBlobMsg;
241 class VisualDebugClient
247 RunSynchronously = 0,
248 RunAsynchronously = 1
251 static KyUInt32 GetInfiniteWaitDelay() {
return KY_WAIT_INFINITE; }
258 #endif // Navigation_VisualDebugClient_H
RunMode
Enumerated the running mode of the VisualDebugClient.
Definition: visualdebugclient.h:67
Base interface for a class that opens a file on disk.
Definition: fileopener.h:35
The VisualDebugClient class manages the retrieval of data from a VisualDebugServer running in the gam...
Definition: visualdebugclient.h:61
void CloseConnection()
Closes the current network socket connection, if any.
static KyUInt32 GetInfiniteWaitDelay()
Defines a special value that can be passed to WaitWhileEstablishingConnection to block execution in t...
Definition: visualdebugclient.h:85
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
KyResult ConnectToServer(const char *ipAddress, KyUInt32 port, RunMode runMode=RunSynchronously)
Initiates a new connection to the VisualDebugServer listening on the specified host and port...
Operations are done in the main thread.
Definition: visualdebugclient.h:69
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:118
KyResult SendFlatBlob(KyUInt32 blobtypeId, KyUInt32 size, char *blob)
Sends a flat blob (with no Array inside).
The BlobHandler class is a top-level mechanism for serializing blobs between objects in memory and fi...
Definition: blobhandler.h:45
Definition: gamekitcrowddispersion.h:20
#define KY_ERROR
Shorthand for Kaim::Result::Failure.
Definition: types.h:272
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
bool WaitWhileEstablishingConnection(KyUInt32 maxDelayMilliseconds)
For internal use.
void StartListeningForAvailableServers(KyUInt32 port, RunMode runMode=RunAsynchronously)
RunAsynchronously is highly recommended to run this in a seperated thread because listening for Wii U...
BaseBlobBuilder is an abstract base class that builds a blob within a contiguous block of memory...
Definition: baseblobbuilder.h:30
Operations are made in separate threads.
Definition: visualdebugclient.h:70
KyResult SendEndOfSynchronization()
Must be send after having sent or received data for synchronization.
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
KyResult SetupReceiverRegistry(MessageReceiverRegistry &receiverRegistry)
Setup the internal receiver registry.
bool IsReceptionPipelineEmpty()
Check if everything was received.
Definition: visualdebugclient.h:114
bool IsConnected() const
Indicates whether the VisualDebugClient is connected and SendEndOfSynchronization was called...
KyResult Update()
Receives all messages since the last call to Update(), and processes them by calling the receivers se...
Abstract class for all queries.
Definition: iquery.h:133
T * Build(BlobHandler< T > &blobHandler)
This method:Calls DoBuild() in COUNT mode to determine the amount of memory needed for the blob to be...
Definition: baseblobbuilder.h:215
bool IsConnectionEstablished() const
Indicates whether ThreadMgr has established a connection.