| 1085 | } |
| 1086 | else if (frame.payloadLength <= 0xFFFF) |
| 1087 | { |
| 1088 | output[headerOffset++] = static_cast<uint8_t>((frame.masked ? 0x80 : 0) | 126); |
| 1089 | output[headerOffset++] = static_cast<uint8_t>((frame.payloadLength >> 8) & 0xFF); |
| 1090 | output[headerOffset++] = static_cast<uint8_t>(frame.payloadLength & 0xFF); |
| 1091 | } |
| 1092 | else |
| 1093 | { |
| 1094 | output[headerOffset++] = static_cast<uint8_t>((frame.masked ? 0x80 : 0) | 127); |
| 1095 | for (int shift = 56; shift >= 0; shift -= 8) |
| 1096 | { |
| 1097 | output[headerOffset++] = static_cast<uint8_t>((frame.payloadLength >> shift) & 0xFF); |
| 1098 | } |
| 1099 | } |
| 1100 | |
| 1101 | if (frame.masked) |
| 1102 | { |