I have a websocket HTML5 page that receives data from the server, but curiously the onmessage
event seems to fire multiple times for long strings.
w.onmessage = function(e) {
console.log ("\n\n message received... "+e.data);
}
If I have a string 3000 characters long, the above code will print out the first 2048 characters and then whatever is left over on the second time around.
Is there anyway for me to check for something like (pseudo-code) (e.state == FINISHED
) or (e.state != UPDATING
) or something so I do开发者_StackOverflown't execute my code until I have all of the data? Right now, the onmessage
function is getting called multiple times when it receives a message and this is messing up the code.
Can you split the string in the server side? Add some thing at the end to indicate that there are more characters behind.
精彩评论