I tried looking around for some information but could not find any. I am using the latest build: 21.0.1180.83 m.
I have a C++ server I am working on, and after the handshake I am sending Chrome the following: "10000001000000100110100001101001" Which should just be "hi", correct? But for some reason chrome is not doing anything. My server is sending the data correctly--I was messing around with the bits and had a chrome error saying: One or more reserved bits are on: reserved2 = 1, reserved3 = 1. So, I know that chrome is receiving correctly.
ws.onmessage = function (evt)
{
var received_msg = evt.data;
alert(received_msg);
};
To my knowledge that should be correct, unless I am missing something ... Any help would be appreciated.
EDIT I solved my issue, it seems like I was not putting the bytes together correctly ...
Here is a piece of code i chopped together to fix ... (dont hate)
string construct_data ( string data ) {
string return_value = "";
/* 0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-------+-+-------------+-------------------------------+
|F|R|R|R| opcode|M| Payload len | Extended payload length |
|I|S|S|S| (4) |A| (7) | (16/64) |
|N|V|V|V| |S| | (if payload len==126/127) |
| |1|2|3| |K| | |
+-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
| Extended payload length continued, if payload len == 127 |
+ - - - - - - - - - - - - - - - +-------------------------------+
| |Masking-key, if MASK set to 1 |
+-------------------------------+-------------------------------+
| Masking-key (continued) | Payload Data |
+-------------------------------- - - - - - - - - - - - - - - - +
: Payload Data continued ... :
+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
| Payload Data continued ... |
+---------------------------------------------------------------+*/
char unmasked = 129;
char size;
if ( data.size() <= 125 ) {
size = data.size();
} else if ( data.size() > 125 && data.size() <= 65535) {
size = 126;
} else if ( data.size() > 65535 ) {
size = 127;
}
stringstream it_um;
stringstream it_s;
for ( int i = 0; i < 1 ; i++ )
it_um << unmasked;
for ( int i = 0; i < 1; i++ )
it_s << size;
std::string raw_unmask;
std::string raw_size;
raw_unmask = it_um.str();
raw_size = it_s.str();
string raw_data = raw_unmask + raw_size + data;
return_value.append(raw_data);
return return_value;
}