char newline = '\n';
for ( i = 5 ; i < payload_length && payload[i] != newline ; i++ )
{
username[i-5] = payload[i];
username[i-4] = '\0';
}
This is part of some server code that I CANNOT modify. I’m writing the client side. I’ve tried the following
websocket.send("SEND "+name+"\n"+message);
websocket.send("SEND "+name+"\\n"+message);
websocket.send("SEND "+name+"\r\n"+message);
None work. It doesn’t stop at the newline. If i set newline to ‘|’ and then put in ‘|’ in websocket.send then everything works fine. Any ideas?
You can control in your c code what exactly arrives from the JS side of things by placing
in your loop, which prints the numeric value of the current chr and the chr itself.
If you check the newline chr:
output will be:
I guess what you send in your example are the characters
\(92) andn(110) so i would sugest you try the following to specify you newline character in JS: