Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var connNo = 0;
- var sum = 0;
- var ports = [];
- var portNo = 0;
- onconnect = function(e) {
- connNo += 1;
- var port = e.ports[0];
- ports[portNo] = port;
- portNo++;
- for(i=0; i<portNo; i++)
- ports[i].postMessage('Connection #' + connNo);
- //port.postMessage('Connection #' + connNo);
- port.onmessage = function(e) {
- sum += parseInt(e.data);
- for(i=0;i<portNo;i++){
- ports[i].postMessage(sum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement