2013-04-23 12:18:07 +08:00
|
|
|
EventEmitter = require('events').EventEmitter
|
2013-04-27 19:13:24 +08:00
|
|
|
send = process.atomBinding('ipc').send
|
2013-04-23 12:18:07 +08:00
|
|
|
|
|
|
|
class Ipc extends EventEmitter
|
|
|
|
constructor: ->
|
|
|
|
process.on 'ATOM_INTERNAL_MESSAGE', (args...) =>
|
2013-04-23 20:57:14 +08:00
|
|
|
@emit(args...)
|
2013-04-23 21:52:19 +08:00
|
|
|
process.on 'ATOM_INTERNAL_MESSAGE_SYNC', (args...) =>
|
|
|
|
@emit(args...)
|
2013-04-23 12:18:07 +08:00
|
|
|
|
2013-04-27 19:13:24 +08:00
|
|
|
send: (processId, routingId, args...) ->
|
|
|
|
@sendChannel(processId, routingId, 'message', args...)
|
2013-04-23 17:21:34 +08:00
|
|
|
|
|
|
|
sendChannel: (args...) ->
|
2013-04-23 20:57:14 +08:00
|
|
|
send('ATOM_INTERNAL_MESSAGE', args...)
|
2013-04-23 12:18:07 +08:00
|
|
|
|
|
|
|
module.exports = new Ipc
|