Access a function in main window from renderer process in Electron

老子叫甜甜 提交于 2019-12-11 04:11:48

问题


I am integrating the Skype web sdk conversation control in my application. I have

  • the main process in the background
  • there is a main window (a separate renderer process)
  • there are chat windows (separate renderer processes) which have been opened by clicking on the main window

In the main window, I am initialising the Skype Web SDK, signing in the user and then fetching the contact list. Now when I click on a contact, it should open separate chat window and start the conversation control in this window.

The skype call in main window looks something like

skypeWebApi.renderConversation(containerDivReference)

The skypeWebApi.renderConversation function is available in main window renderer process and containerDivReference is available in the chat window renderer process

To achieve this, I Passed skypeWebApi reference to chat window renderer process. However, due to serialization, renderConversation isn't available here. So it doesn't work.

Is there any way to access this function placed within the main window renderer process?

I tried to send an event to main window with the containerDiv reference, but that didn't work either. Plus, it didn't seem like a very clean solution as there were a lot of events going to and fro.

Right now what I am trying to achieve is communication between 2 separate renderer process.

I can also restructure my code to initialise the SDK in main process and let these renderer processes (main window and chat window) call the functions in the main process

Any help?

来源:https://stackoverflow.com/questions/41485770/access-a-function-in-main-window-from-renderer-process-in-electron

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!