Closed JoeHartzell closed 1 year ago
Just confirmed that the PR resolves the issue and my frames now successfully communicate! 🎉 It might be worth following up this issue by adding an example to the repo using iframes.
Just giving this a friendly bump @jsonnull . Would love to see this merged as I think it blocks multi-window support as well. Also more than happy to help on any other roadmap items. This is by far the best way to work with electron ipc communication.
Hey, thanks for the friendly bump and all the effort here. I'll get this merged in and get a release out. If you're interested in contributing more, let's chat sometime!
This fix is released in electron-trpc@0.5.1
. Thanks again!
Summary
I have a use case that involves using
iframes
and tRPC to communicate between each frame and the main thread. After spending some time debugging it seems thathandleIPCMessage
replies to the sender usingevent.sender.send
which will always reply to the main frame.References
Electron Docs
handleIPCMessage code
Solution
I think the solution here is pretty simple.
handleIPCMessage
should be able to useevent.reply
to respond to incoming events as stated by the Electron docs. This would also involve updating the types on theevent
parameters to useipcMainEvent
instead ofIpcMainInvokeEvent
.Example
Current implementation
Suggested change
Contributing
Would be more than happy to make a PR with the suggested changes above.
Versions