How to use the electron.ipcMain function in electron

To help you get started, we’ve selected a few electron examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yjlintw / comic-reader / main.js View on Github external
const electron = require('electron');
const {app, BrowserWindow, dialog} = electron;
const path = require('path');
const url = require('url');
const settings = require('electron-settings');
const log = require('electron-log');
const {autoUpdater} = require("electron-updater");
const EA = require("electron-analytics");
const ipc = electron.ipcMain;
EA.init("Bkles-YA1-");

require('electron-debug')({showDevTools: false});

// Logging
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = "info";
// autoUpdater.autoDownload = false;
log.info('App Starting');

let manualupdate = false;

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
// require('electron-context-menu')();
github ccfish86 / sctalk / clients / tt-rapido / service / main / ipcMainOn.js View on Github external
exports.ipcInit = function() {
  var ipc = require('electron').ipcMain;

  // main window
  ipc.on('send-data', function(event, m, m2) {
    global.priorConn.senddata(m);
  });

  ipc.on('login-req', function(event, username, passwd, autologin, savePassword) {
    loginAction.dologin(username, passwd, autologin, savePassword);
  });

  ipc.on('get-myinfo', (event, arg) => {
    // myInfoObj = UserInfoAction.getUserInfo(global.myUserId);
    let myInfoAsynResult = UserInfoAction.getUserInfo(global.myUserId);
    myInfoAsynResult.then(infoObj => {
      console.info('myInfoAsynResult ' + global.myUserId)
      // event.returnValue = JSON.stringify(myInfoObj);
github microsoft / VoTT / main.js View on Github external
const electron = require('electron');
// Module to control application life.
const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;
const windowStateKeeper = require('electron-window-state');
const path = require('path');
const url = require('url');
// To access the version defined in package.json
require('pkginfo')(module, 'version');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let ipcMain = require('electron').ipcMain;

function createWindow () {

  let mainWindowState = windowStateKeeper({
    defaultWidth: 800,
    defaultHeight: 600
  });

  // Create the browser window.
  mainWindow = new BrowserWindow({
      width: mainWindowState.width,
      height: mainWindowState.height,
      x: 0,
      y: 0,
      minHeight: 480,
      minWidth: 480,
github wildfirechat / pc-chat / src / js / platform.js View on Github external
{
                items
            }
        
    );
}

export function connect(userId, token) {
    wfc.connect(userId, token);
}

// pc
export const remote = require('electron').remote;
export const ipcRenderer = require('electron').ipcRenderer;
export const ipcMain = require('electron').ipcMain;
export const fs = require('file-system').fs;
export const currentWindow = require('electron').remote.getCurrentWindow();
export const BrowserWindow = require('electron').remote.BrowserWindow;
export const AppPath = require('electron').remote.app.getAppPath();

// for web
export const ContextMenuTrigger = null;
export function hideMenu() { }
export const PostMessageEventEmitter = null;
github symphonyoss / SymphonyElectron / js / notify / electron-notify.js View on Github external
// code here adapted from https://www.npmjs.com/package/electron-notify
// made following changes:
// - place notification in corner of screen
// - notification color
// - notification flash/blink
// - custom design for symphony notification style
// - if screen added/removed or size change then close all notifications
//
const path = require('path');
const fs = require('fs');
const electron = require('electron');
const asyncMap = require('async.map');
const asyncMapSeries = require('async.mapseries');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const ipc = electron.ipcMain;
const { isMac, isNodeEnv } = require('../utils/misc');
const log = require('../log.js');
const logLevels = require('../enums/logLevels.js');
const i18n = require('../translation/i18n');
// maximum number of notifications that can be queued, after limit is
// reached then error func callback will be invoked.
const MAX_QUEUE_SIZE = 30;

let AnimationQueue = require('./AnimationQueue.js');

// Array of windows with currently showing notifications
let activeNotifications = [];

// Recycle windows
let inactiveWindows = [];
github dmfarcas / clipboard-manager / main.js View on Github external
'use strict';
const electron = require('electron');
const app = electron.app; // Module to control application life.
const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
const clipboard = require('electron').clipboard;
const globalShortcut = electron.globalShortcut;
const ipcMain = require('electron').ipcMain;
const ipcRender = require('electron').ipcMain;
const Tray = electron.Tray;
const Menu = electron.Menu;


// Notifications
const notifier = require('node-notifier');
const path = require('path');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let appIcon = null;

// shortcut memory
let oldcopykeys = [];
github joe-re / cafe-pitch / src / browser / presentation_window.ts View on Github external
constructor() {
    if (PresentationWindow.instance) throw new Error('must use the getInstance.');
    electron.ipcMain.on(EVENTS.PRESENTATION_WINDOW.RENDERER.REQUEST_START_PRESENTATION, this.hanldRequestStartPresentation.bind( this ) );
    electron.ipcMain.on(EVENTS.PRESENTATION_WINDOW.RENDERER.REQUEST_MESSAGE, (ev) => {
      ev.returnValue = this.text;
    });
  };
github m0n0l0c0 / electron-router / router.js View on Github external
(function (factory) {
  if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
    try {
      let ele = require('electron')
      let ipc = ele.ipcMain
      let proc = 1
      let remote = { BrowserWindow: ele.BrowserWindow }
      if (!ipc) {
        proc = 0
        ipc = ele.ipcRenderer
        remote = ele.remote
      }
      module.exports = factory(require('eventemitter3'), ipc, remote, require('lodash'), require('uuid'), proc)
    } catch (e) {
      throw new Error('This module only works on an Electron environment!!', e)
    }
  } else {
    throw new Error('This module only works on an Node-Electron environment!!')
  }
})(function (EventEmitter, ipc, remote, lo, uuid, procSide) {
github DanielGarciaMandillo / angular-java / build / electron / platform / electron_app.js View on Github external
return new Promise(function (resolve) {
        electron.ipcMain.once(electron_message_bus_1.ELECTRON_READY, function (ev) {
            ev.returnValue = 'ok';
            resolve();
        });
    });
}