mirror of
https://git.hmsn.ink/kospo/helptalk/user.git
synced 2026-03-20 16:13:34 +09:00
first
This commit is contained in:
22
public/js/shared-worker.js
Normal file
22
public/js/shared-worker.js
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
const clients = [];
|
||||
|
||||
self.onconnect = function(e) {
|
||||
console.log(1)
|
||||
const port = e.ports[0];
|
||||
clients.push(port)
|
||||
|
||||
port.onmessage = function(e) {
|
||||
const message = e.data;
|
||||
|
||||
clients.forEach(client => client.postMessage(message))
|
||||
}
|
||||
|
||||
port.isMaster = function() {
|
||||
clients.forEach(client => client.postMessage({tabId: port.tabId}))
|
||||
}
|
||||
|
||||
port.setMaster = function(tabId) {
|
||||
port.tabId = tabId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user