sharedworker-partitioning-helper.js (412B)
1 let messages = {}; 2 3 onconnect = function(e) { 4 let port = e.ports[0]; 5 6 port.addEventListener('message', function(e) { 7 const action = e.data.action; 8 const from = e.data.from; 9 10 if (action === 'record') { 11 messages[from] = true; 12 port.postMessage({ack: from}); 13 } 14 15 if (action === 'retrieve') { 16 port.postMessage({ack: from, messages: messages}); 17 } 18 }); 19 20 port.start(); 21 };