MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / WriteFrame

Method WriteFrame

Sources/Jazz2/UI/DiscordRpcClient.cpp:278–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

276 }
277
278 bool DiscordRpcClient::WriteFrame(Opcodes opcode, const char* buffer, std::uint32_t bufferSize)
279 {
280 char frameHeader[8];
281 *(std::uint32_t*)&frameHeader[0] = (std::uint32_t)opcode;
282 *(std::uint32_t*)&frameHeader[4] = bufferSize;
283
284#if defined(DEATH_TARGET_WINDOWS)
285 DWORD bytesWritten = 0;
286 return ::WriteFile(_hPipe, frameHeader, sizeof(frameHeader), &bytesWritten, NULL) &&
287 ::WriteFile(_hPipe, buffer, bufferSize, &bytesWritten, NULL);
288#else
289 if (::write(_sockFd, frameHeader, sizeof(frameHeader)) < 0) {
290 return false;
291 }
292
293 std::int32_t bytesTotal = 0;
294 while (bytesTotal < bufferSize) {
295 std::int32_t bytesWritten = ::write(_sockFd, buffer + bytesTotal, bufferSize - bytesTotal);
296 if (bytesWritten < 0) {
297 return false;
298 }
299 bytesTotal += bytesWritten;
300 }
301 return true;
302#endif
303 }
304
305 void DiscordRpcClient::OnBackgroundThread(void* args)
306 {

Callers 1

OnBackgroundThreadMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected