How to use the ipc.on function in ipc

To help you get started, we’ve selected a few ipc 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 docker / kitematic / meteor / client / lib / ipc.js View on Github external
var ipc = require('ipc');

// Listen for auto updates
ipc.on('notify', function (message) {
  if (message === 'window:update-available') {
    Session.set('updateAvailable', true);
  }
  if (message === 'application:quit') {
    VirtualBox.saveVMState('boot2docker-vm', function (err) {
      if (err) {
        console.log(err);
      }
    });
  }
});
github docker / docker.github.io / meteor / client / lib / ipc.js View on Github external
var ipc = require('ipc');

// Listen for auto updates
ipc.on('notify', function (message) {
  if (message === 'window:update-available') {
    Session.set('updateAvailable', true);
  }
  if (message === 'application:quit') {
    VirtualBox.saveVMState('boot2docker-vm', function (err) {
      if (err) {
        console.log(err);
      }
    });
  }
});
github ajam / aufbau / index.js View on Github external
function createMainWindow () {
	const win = new BrowserWindow({
		width: 1280,
		height: 768,
		resizable: true,
		title: options.page_title
	})

	// Set the download directory to being off of the user's home folder
	var tilde_downloads = path.join(app.getHomeDir(), 'Downloads')
	win.webContents.session.setDownloadPath(tilde_downloads)

	// Allow for messages to be sent from client
	ipc.on('asynchronous-message', sendPath('async'))
	ipc.on('synchronous-message', sendPath('sync'))

	win.webContents.on('did-finish-load', function (webContents) {
		var page_title = webContents.sender.getTitle()
		var index_path
		var home_btn_css
		var home_btn_js
		if (page_title != 'Aufbau home') {
			// Add css
			home_btn_css = fs.readFileSync(path.join(__dirname, 'home-btn.css'), 'utf-8')
			webContents.sender.insertCSS(home_btn_css)
			
			// Add home button
			index_path = path.join(__dirname, 'www', 'index.html')
			home_btn_js = fs.readFileSync(path.join(__dirname, 'home-btn.jst'), 'utf-8').replace('{{index_path}}', index_path)
			webContents.sender.executeJavaScript(home_btn_js)
github ajam / aufbau / index.js View on Github external
function createMainWindow () {
	const win = new BrowserWindow({
		width: 1280,
		height: 768,
		resizable: true,
		title: options.page_title
	})

	// Set the download directory to being off of the user's home folder
	var tilde_downloads = path.join(app.getHomeDir(), 'Downloads')
	win.webContents.session.setDownloadPath(tilde_downloads)

	// Allow for messages to be sent from client
	ipc.on('asynchronous-message', sendPath('async'))
	ipc.on('synchronous-message', sendPath('sync'))

	win.webContents.on('did-finish-load', function (webContents) {
		var page_title = webContents.sender.getTitle()
		var index_path
		var home_btn_css
		var home_btn_js
		if (page_title != 'Aufbau home') {
			// Add css
			home_btn_css = fs.readFileSync(path.join(__dirname, 'home-btn.css'), 'utf-8')
			webContents.sender.insertCSS(home_btn_css)
			
			// Add home button
			index_path = path.join(__dirname, 'www', 'index.html')
			home_btn_js = fs.readFileSync(path.join(__dirname, 'home-btn.jst'), 'utf-8').replace('{{index_path}}', index_path)
			webContents.sender.executeJavaScript(home_btn_js)
github vitalybe / radio-stream / radio-stream-www / app / utils / desktop_ipc.js View on Github external
export function connect() {
// For desktop mode only
    if (!__WEB__) {

        require('ipc').on('log', function (msg) {
            logger.debug(msg);
        });

        require('ipc').on('playPauseToggle', function () {
            logger.debug("received message: playPauseToggle");
            if (store.player) {
                store.player.togglePlayPause();
            }
        });

        require('ipc').on('idle', function (idleOutput) {
            // logger.debug("received idle: " + idleOutput);
            const idleSeconds = parseInt(idleOutput);

            if (idleSeconds > 180 && store.player && store.player.isPlaying) {
                logger.debug("idle too long - pausing song");
                store.player.pause();
            }

        });

        // TODO: replace/remove
        //const ipcRenderer = require('electron').ipcRenderer;
        //observeStore(state => ({
        //    currentSong: state.currentSongAsync.data,
        //    artistImage: state.currentArtistImage
        //}), data => {
github pcman-bbs / plasmon / app.js View on Github external
continue;
					}
					var b5index = 'x' + str.charCodeAt(i).toString(16).toUpperCase() +
						str.charCodeAt(i+1).toString(16).toUpperCase();
					if (b2u_table[b5index]) {
						data += b2u_table[b5index];
						++i;
					} else { // Not a big5 char
						data += str.charAt(i);
					}
				}
				return data;
			}
		});
		ipc.send('connect', this.url);
		ipc.on('data', pcman.receive.bind(pcman));
		document.title = this.url;
		document.addEventListener('focus', this.set_focus, false);
		this.set_focus();
		this.resize();
	}
	set_focus(e) {
github vitalybe / radio-stream / radio-stream-www / app / utils / desktop_ipc.js View on Github external
export function connect() {
// For desktop mode only
    if (!__WEB__) {

        require('ipc').on('log', function (msg) {
            logger.debug(msg);
        });

        require('ipc').on('playPauseToggle', function () {
            logger.debug("received message: playPauseToggle");
            if (store.player) {
                store.player.togglePlayPause();
            }
        });

        require('ipc').on('idle', function (idleOutput) {
            // logger.debug("received idle: " + idleOutput);
            const idleSeconds = parseInt(idleOutput);

            if (idleSeconds > 180 && store.player && store.player.isPlaying) {
                logger.debug("idle too long - pausing song");
github coolzilj / xueqiu-stock / main.js View on Github external
menu.on('ready', function ready() {

  var canQuit = false;
  menu.app.on('will-quit', function tryQuit(e) {
    if (canQuit) return true;
    menu.window = undefined;
    e.preventDefault();
  });

  ipc.on('terminate', function terminate(e) {
    canQuit = true;
    menu.app.terminate();
  });

  ipc.on('open-dir', function openDir(e) {
    shell.showItemInFolder(path.join(conf.exec.cwd, 'config.json'));
  });


  var conf = loadConfig();

  function loadConfig() {
    var dir = path.join(menu.app.getPath('userData'), 'data');
    var configFile = dir + '/config.json';
    var conf, data;
github brrd / Abricotine / app / renderer / ipc-client.js View on Github external
function IpcClient () {
    this.callbacks = [];
    this.windowId = remote.getCurrentWindow().id;
    var that = this,
        runCallback = function (key, value, id, windowId) {
            if (typeof id !== "undefined" && typeof that.callbacks[id] === "function" && windowId === that.windowId) {
                var callback = that.callbacks[id];
                callback(value);
            }
        };
    ipc.on("get-reply", runCallback);
    ipc.on("set-reply", runCallback);
    ipc.on("trigger-reply", runCallback);
}

ipc

A simple inter process communication library along with distributed election algorithm (Bully) for Node.js

Unknown
Latest version published 12 years ago

Package Health Score

30 / 100
Full package analysis

Popular ipc functions