Basic fragmented send feature
This commit is contained in:
@@ -35,6 +35,7 @@ const std::string_view ERR_TOO_BIG_MESSAGE_INFLATION("Received too big message,
|
||||
const std::string_view ERR_INVALID_CLOSE_PAYLOAD("Received invalid close payload");
|
||||
|
||||
enum OpCode : unsigned char {
|
||||
CONTINUATION = 0,
|
||||
TEXT = 1,
|
||||
BINARY = 2,
|
||||
CLOSE = 8,
|
||||
@@ -205,7 +206,7 @@ enum {
|
||||
};
|
||||
|
||||
template <bool isServer>
|
||||
static inline size_t formatMessage(char *dst, const char *src, size_t length, OpCode opCode, size_t reportedLength, bool compressed) {
|
||||
static inline size_t formatMessage(char *dst, const char *src, size_t length, OpCode opCode, size_t reportedLength, bool compressed, bool fin) {
|
||||
size_t messageLength;
|
||||
size_t headerLength;
|
||||
if (reportedLength < 126) {
|
||||
@@ -223,11 +224,9 @@ static inline size_t formatMessage(char *dst, const char *src, size_t length, Op
|
||||
memcpy(&dst[2], &tmp, sizeof(uint64_t));
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
dst[0] = (char) ((flags & SND_NO_FIN ? 0 : 128) | (compressed ? SND_COMPRESSED : 0));
|
||||
if (!(flags & SND_CONTINUATION)) {
|
||||
dst[0] |= (char) opCode;
|
||||
}
|
||||
dst[0] = (char) ((fin ? 128 : 0) | ((compressed && opCode) ? SND_COMPRESSED : 0) | (char) opCode);
|
||||
|
||||
//printf("%d\n", (int)dst[0]);
|
||||
|
||||
char mask[4];
|
||||
if (!isServer) {
|
||||
|
||||
Reference in New Issue
Block a user