electron-webapps / meteor-electron

Meteor Electron, the easiest way to create a desktop Meteor application
MIT License
326 stars 48 forks source link

how to use ipc #111

Open juceling opened 7 years ago

juceling commented 7 years ago

hi. thx for your package. I`m newbie in programming.

I`m asking how to use ipc with my meteor app. I want to send ipc mesasge to electron main process. I found "onWindowEvent" & "onEvent" method at preload.js. so, I used "onWindowEvent". But nothing was happen. so, I inserted some code to test with ipc communication... like below...

// client/index.js
Electron = {
  // ...
  send: function() {},
  // ...
}

// preload.js
var ipc = require('electron').ipcRenderer;
ElectronImplementation = {
  // ...
  send: function(event, opts) {
      ipc.send(event, opts);
  },
  // ...
}

// proxyWindowEvents.js
var ipcMain = require('ipc-main');
var proxyWindowEvents = function(window) {
  ipc.on('do-test', function(event, arg) {
    // just for checking... 
    dialog.showOpenDialog(window, {
      title: "ipc test done."
    });
  });
}

// my meteor code with coffee-script
Electron.send "do-test", "whatsup"

but, nothing was happen. dialog is not opened.

this is not correct implementation? or I`m missing something usage with already implemented codes?

I`m newbie in programming. please anybody tell me anything about this...

thank you for reading my ugly english