I may have answered this question for myself but I need to sanity check...
I have one tab broadcasting to another over the broadcast channel every 500 ms. The second tab is set to receive broadcasts and print them in the console log.
Sending tab:
const crossTraffic = new BroadcastChannel('crossTraffic');
const queueInterval = setInterval(function(){
crossTraffic.postMessage({action: 'keepalive', cTime: Date.now()});
console.log(`cTime sent ${Date.now()}`);
}
},500);
Receiving tab:
const crossTraffic = new BroadcastChannel('crossTraffic');
crossTraffic.onmessage = function(e){
if (e.data.action === 'keepalive'){
console.log(`ctime received ${e.data.cTime}`);
}
}
I've observed the following: no matter what I set the queueInterval time for, the receiving tab will never receive a broadcast more than once every 1,000 ms.
Is this normal behavior for the broadcast channel or is it possible to receive messages at a smaller interval than 1,000 ms?