Replies: 2 comments 3 replies
This comment was marked as spam.
This comment was marked as spam.
-
|
Hey @Bloodiko, please disregard the "Albert Hilton" guy who is not affiliated with our project. Communication with a Web Worker (not to be confused with Cloudflare Workers 🙂) should work today using the MessagePort transport.
Voila, you now have an RPC session with your Worker. Moreover, since the RPC is over a separate MessageChannel, it doesn't interfere with any other postMessage() communications you might want to perform with the worker. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
tldr: Using this to communicate efficiently with Web API Workers, which basically use the same "Websocket" structure, might be a nice feature for this lib.
Explanation
Currently, the library expects an web endpoint http or a Websocket endpoint.
Using this library, to utilize rpc to efficiently pass (heavy/ async) work between the main context and a web worker (Web workers API ) could make the existing API much easier.
Additionally, the difference between a Websockets send() (with strings only) and the Web workers postMessage() are relatively marginal.
Therefore I assume it could be utilized to allow the same behavior for Web workers.
Http connection -->
worker.postMessage()Websockets connection -->
worker.connect()caveats
To be fair, I have no idea how you would be able to tell it to connect to an worker instead of an Websocket/http endpoint.
Maybe by passing the web worker object to the connection creator?
Please tell me your thoughts about this idea.
Curious if that would be possible.
Beta Was this translation helpful? Give feedback.
All reactions