웹 작업자 강좌

1466 단어 worker

 
var worker = new SharedWorker('work.js'); 

worker.port.addEventListener('message', function(e) { 

    alert(e.data); 

}, false); 

worker.port.start(); 

worker.port.postMessage(msg);

 
 
var connect_number = 0; 

onconnect = function(e) { 

    connect_number =connect_number+ 1; 

    var port = e.ports[0]; 

    port.postMessage('The current connection number is ' 

                              + connect_number); 

    port.onmessage = function(e) { 

        port.postMessage('Request msg'); 

    }; 

}; 

좋은 웹페이지 즐겨찾기