WebTorrent process
* Separate hidden window, with its own renderer process, for WebTorrent (Must be a window. You cannot run WebRTC at all in a Web Worker, and you can't run it well in a node process like the electron main process.) * Disabled the create-torrent-modal for now. That gives us a consistent UX regardless of whether the user dragged files or folders onto the app or opened the Create New Torrent menu item. * Main process routes all messages between the main and webtorrent windows. * The renderer index.js is smaller now (but still too big), with the WebTorrent interface moved to webtorrent.js / it's own process. * The UI should be faster now, and should not lag under load.
This commit is contained in:
22
main/ipc.js
22
main/ipc.js
@@ -69,6 +69,28 @@ function init () {
|
||||
menu.onPlayerClose()
|
||||
shortcuts.unregisterPlayerShortcuts()
|
||||
})
|
||||
|
||||
// Capture all events
|
||||
var oldEmit = ipcMain.emit
|
||||
ipcMain.emit = function (name, e, ...args) {
|
||||
// Relay messages between the main window and the WebTorrent hidden window
|
||||
if (name.startsWith('wt-')) {
|
||||
var recipient, recipientStr
|
||||
if (e.sender.browserWindowOptions.title === 'webtorrent-hidden-window') {
|
||||
recipient = windows.main
|
||||
recipientStr = 'main'
|
||||
} else {
|
||||
recipient = windows.webtorrent
|
||||
recipientStr = 'webtorrent'
|
||||
}
|
||||
console.log('sending %s to %s', name, recipientStr)
|
||||
recipient.send(name, ...args)
|
||||
return
|
||||
}
|
||||
|
||||
// Emit all other events normally
|
||||
oldEmit.call(ipcMain, name, e, ...args)
|
||||
}
|
||||
}
|
||||
|
||||
function setBounds (bounds, maximize) {
|
||||
|
||||
Reference in New Issue
Block a user