Quantcast
Channel: 2D Latest Topics
Viewing all articles
Browse latest Browse all 623

My javascript websockets seem to be buffering incoming messages

$
0
0
Im receiving websocket messages on my webpage, and i'm trying to calculate the frequency at which they are received. I do this like so:
let startTime = new Date();
ws.onmessage = function (evt)
{

prevData = recivedData;
var receivedMsg = evt.data;

recivedData = JSON.parse(receivedMsg);

const endTime = new Date();
const timeDif = endTime - startTime;
startTime = endTime;
console.log(timeDif)
}

But it seems timeDif sometimes is 0, and I find this unlikely. People in other questions of mine have sad that its due to the websocket buffering incoming messages. How do I prevent this?


Viewing all articles
Browse latest Browse all 623

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>