Fix masking calculation in txbuf.

This commit is contained in:
David Baird
2013-11-12 19:00:38 -07:00
parent fc12f28312
commit d678234e90
+2 -1
View File
@@ -342,10 +342,11 @@ class _RealWebSocket : public easywsclient::WebSocket
header[13] = masking_key[3];
}
}
// N.B. - txbuf will keep growing until it can be transmitted over the socket:
txbuf.insert(txbuf.end(), header.begin(), header.end());
txbuf.insert(txbuf.end(), message.begin(), message.end());
if (useMask) {
for (size_t i = 0; i != message.size(); ++i) { txbuf[i+header.size()] ^= masking_key[i&0x3]; }
for (size_t i = 0; i != message.size(); ++i) { *(txbuf.end() - message.size() + i) ^= masking_key[i&0x3]; }
}
}