JAVASCRIPT   8

intracom.js

Guest on 19th August 2021 04:28:04 PM

  1. var connections = 0; // count active connections
  2.  
  3. self.addEventListener("connect", function (e) {
  4.  
  5.         var port = e.ports[0];
  6.         connections++;
  7.  
  8.         var eventReceived=JSON.stringify(e);
  9.         port.addEventListener("message", function (e) {
  10.                 port.postMessage("Hello " + e.data + " (port #" + connections + ")\nData: "+eventReceived);
  11.         }, false);
  12.  
  13.         port.start();
  14. }, false);

Raw Paste


Login or Register to edit or fork this paste. It's free.