Skip to content

Instantly share code, notes, and snippets.

@tobiu
Created March 28, 2022 07:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobiu/47943cd1766f4a6b9f0252b2b840f7d5 to your computer and use it in GitHub Desktop.
Save tobiu/47943cd1766f4a6b9f0252b2b840f7d5 to your computer and use it in GitHub Desktop.
Neo.worker.ServiceBase
class ServiceBase extends Base {
// ..
/**
* @param {Client} client
*/
createMessageChannel(client) {
let me = this,
channel = new MessageChannel(),
port = channel.port2;
channel.port1.onmessage = me.onMessage.bind(me);
me.sendMessage('app', {action: 'registerPort', transfer: port}, [port]);
me.channelPorts.push({
clientId : client.id,
destination: 'app',
port : channel.port1
});
}
}
Neo.applyClassConfig(ServiceBase);
export default ServiceBase;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment