title: How to handle service worker message once for multiple tabs?
body: <p>I have an application and I would like prevent message handling from another tab. </p>
  
  <pre class="lang-js prettyprint-override"><code>//client
  
  var msg_chan = new MessageChannel();
  // Handler for recieving message reply from service worker
  msg_chan.port1.onmessage = function(event){
    if(event.data.error){
      reject(event.data.error);
    }else{
      resolve(event.data);
    }
  };
  const id = (new Date().getTime() / 1000).toFixed()
  // Send message to service worker along with port for reply
  navigator.serviceWorker.controller.postMessage({ message, id }, [msg_chan.port2]);
  
  </code></pre>
  
  <p>In this way, if multiple tabs are opened service worker handles the message in both tabs. </p>
  
  <pre class="lang-js prettyprint-override"><code>// service-worker.js
  self.addEventListener('message', event =&gt; {
    console.log(event.data) // This prints two times if two tabs are open
  })
  </code></pre>
  
  <p>Is it possible to handle message for once?</p>