How to handle weirdly combined websocket messages? How to handle weirdly combined websocket messages? json json

How to handle weirdly combined websocket messages?


My assumption is that you're working only with English/ASCII characters and something probably messed the stream. (NOTE:I am assuming), there are no special characters, if it's so, then I will suggest you pass the entire json string into this function:

function cleanString(input) {    var output = "";    for (var i=0; i<input.length; i++) {        if (input.charCodeAt(i) <= 127) {            output += input.charAt(i);        }    }    console.log(output);}//examplecleanString("�~�")