Send message to window directly when passing BrowserWindow for ipc.send.
This commit is contained in:
parent
66c35e4517
commit
354b0c8e39
1 changed files with 10 additions and 1 deletions
|
@ -1,6 +1,15 @@
|
|||
EventEmitter = require('events').EventEmitter
|
||||
send = process.atomBinding('ipc').send
|
||||
|
||||
sendWrap = (channel, processId, routingId, args...) ->
|
||||
BrowserWindow = require 'browser_window'
|
||||
if processId?.constructor is BrowserWindow
|
||||
window = processId
|
||||
processId = window.getProcessId()
|
||||
routingId = window.getRoutingId()
|
||||
|
||||
send channel, processId, routingId, args...
|
||||
|
||||
class Ipc extends EventEmitter
|
||||
constructor: ->
|
||||
process.on 'ATOM_INTERNAL_MESSAGE', (args...) =>
|
||||
|
@ -12,6 +21,6 @@ class Ipc extends EventEmitter
|
|||
@sendChannel(processId, routingId, 'message', args...)
|
||||
|
||||
sendChannel: (args...) ->
|
||||
send('ATOM_INTERNAL_MESSAGE', args...)
|
||||
sendWrap('ATOM_INTERNAL_MESSAGE', args...)
|
||||
|
||||
module.exports = new Ipc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue