- From: Ian Hickson <ian@hixie.ch>
- Date: Fri, 8 Aug 2008 19:28:43 +0000 (UTC)
On Fri, 8 Aug 2008, Jonas Sicking wrote: > > > > > > worker = createSharedWorker("foo", "bar.js"); > > > worker.addEventListener("message", handler, false); > > > worker.postMessage("wassup dude, i just connected"); > > > > How would the worker distinguish that from the original "parent" > > sending the same message? > > Why would the original parent same the message twice? Of course > applications following their own application level protocols is going to > break themselves. The whole point of capabilities-based systems is that you can pass these communcation ports over to unknown entities and don't have to trust that they won't screw up your protocol. For example, you could create a shared worker to handle all the requests from all the gadgets hosted on a user's home page and just pass the worker off to them each time: // a new gadget has been created var worker = createSharedWorker('gadget-api.js', 'gadgets'); gadget.postMessage('here is the gadget API', worker.port); What you're proposing would be way more complex -- now you'd have to create the pipe separately, you'd have to have the worker know how to handle both a new connection from its parent as well as its parent saying it wants a new pipe for a gadget, you'd have lifetime issues as you now have extra commucation mechanisms, etc. (This brings up another point, which is that by having Worker objects also be communication end points, we double the complexity of the definitions for worker lifetime, since now they have to deal with both types of channels, not just the one generic type.) -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Friday, 8 August 2008 12:28:43 UTC