MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / SendResponse

Method SendResponse

source/Debugger.cpp:2145–2175  ·  view source on GitHub ↗

Debugger::SendResponse Sends a response to a command, using mResponseBuf.mData as the message body.

Source from the content-addressed store, hash-verified

2143// Sends a response to a command, using mResponseBuf.mData as the message body.
2144//
2145int Debugger::SendResponse()
2146{
2147 ASSERT(!mResponseBuf.mFailed);
2148
2149 char response_header[DEBUGGER_RESPONSE_OVERHEAD];
2150
2151 // Each message is prepended with a stringified integer representing the length of the XML data packet.
2152 Exp32or64(_itoa,_i64toa)(mResponseBuf.mDataUsed + DEBUGGER_XML_TAG_SIZE, response_header, 10);
2153
2154 // The length and XML data are separated by a NULL byte.
2155 char *buf = strchr(response_header, '\0') + 1;
2156
2157 // The XML document tag must always be present to provide XML version and encoding information.
2158 buf += sprintf(buf, "%s", DEBUGGER_XML_TAG);
2159
2160 // Send the response header.
2161 if ( SOCKET_ERROR == send(mSocket, response_header, (int)(buf - response_header), 0)
2162 // Messages sent by the debugger engine must always be NULL terminated.
2163 // Failure to write the last byte should be extremely rare, so no attempt
2164 // is made to recover from that condition.
2165 || DEBUGGER_E_OK != mResponseBuf.Write("\0", 1)
2166 // Send the message body.
2167 || SOCKET_ERROR == send(mSocket, mResponseBuf.mData, (int)mResponseBuf.mDataUsed, 0) )
2168 {
2169 // Unrecoverable error: disconnect the debugger.
2170 return FatalError();
2171 }
2172
2173 mResponseBuf.Clear();
2174 return DEBUGGER_E_OK;
2175}
2176
2177// Debugger::Connect
2178//

Callers

nothing calls this directly

Calls 2

WriteMethod · 0.45
ClearMethod · 0.45

Tested by

no test coverage detected