MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / sendFrame

Method sendFrame

Libraries/Http/HttpWebSocket.cpp:1064–1085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1062 }
1063 else
1064 {
1065 SC_TRY_MSG(not fragmentedMessageInProgress, "HttpWebSocketFrameWriter expected continuation frame");
1066 }
1067 }
1068
1069 const bool requiresMask = scHttpWebSocketRequiresOutgoingMask(endpointRole);
1070 SC_TRY_MSG(frame.masked == requiresMask, "HttpWebSocketFrameWriter invalid frame masking for endpoint role");
1071
1072 const size_t encodedLength =
1073 2 + (frame.payloadLength < 126 ? 0 : (frame.payloadLength <= 0xFFFF ? 2 : 8)) + (frame.masked ? 4 : 0);
1074 SC_TRY_MSG(storage.sizeInBytes() >= encodedLength, "HttpWebSocketFrameWriter header buffer too small");
1075
1076 currentFrame = frame;
1077
1078 uint8_t* output = reinterpret_cast<uint8_t*>(storage.data());
1079 output[0] = static_cast<uint8_t>((frame.fin ? 0x80 : 0) | static_cast<uint8_t>(frame.opcode));
1080
1081 size_t headerOffset = 1;
1082 if (frame.payloadLength < 126)
1083 {
1084 output[headerOffset++] = static_cast<uint8_t>((frame.masked ? 0x80 : 0) | frame.payloadLength);
1085 }
1086 else if (frame.payloadLength <= 0xFFFF)
1087 {
1088 output[headerOffset++] = static_cast<uint8_t>((frame.masked ? 0x80 : 0) | 126);

Callers

nothing calls this directly

Calls 6

beginFrameMethod · 0.80
writePayloadMethod · 0.80
finishFrameMethod · 0.80
ResultClass · 0.50
sizeInBytesMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected