electron/browser/api/lib/ipc.coffee
Cheng Zhao bb69d99423 Use - as filename seperator for coffee script files. Fixes #15.
Also clean unused files and wrong file names.
2013-05-30 20:21:07 +08:00

26 lines
783 B
CoffeeScript

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...) =>
@emit(args...)
process.on 'ATOM_INTERNAL_MESSAGE_SYNC', (args...) =>
@emit(args...)
send: (processId, routingId, args...) ->
@sendChannel(processId, routingId, 'message', args...)
sendChannel: (args...) ->
sendWrap('ATOM_INTERNAL_MESSAGE', args...)
module.exports = new Ipc