How to use ipc - 10 common examples

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 yhat / rodeo / src / browser / jsx / containers / editor-tab-group / editor-tab-group.actions.js View on Github external
return function (dispatch, getState) {
    const state = getState(),
      groupIndex = 0, // assume for now
      group = state[tabGroupName][groupIndex],
      focusedAce = _.find(group.tabs, {id: group.active}),
      aceInstance = focusedAce && getAceInstance(focusedAce.id),
      content = aceInstance && aceInstance.getSession().getValue();

    if (_.isString(content)) {
      return send('saveFile', filename, content)
        .then(() => dispatch(fileIsSaved(group.groupId, focusedAce.id, filename)))
        .catch(error => dispatch(errorCaught(error)));
    }
  };
}
github numediart / ofxMotionMachine / projectGenerator-osx-MoMa / projectGenerator.app / Contents / Resources / app / app.js View on Github external
function getUpdatePath() {

    var path = $("#updateMultiplePath").val();
    if (path === ''){
        path = $("#ofPath").val();
    }

    ipc.send('pickUpdatePath', path); // current path could go here
}
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 maxogden / screencat / app.js View on Github external
peer.on('error', function error (err) {
    ipc.send('icon', 'disconnected')
    console.error('peer error')
    console.error(err)
    ui.containers.content.innerHTML = 'Error connecting! Please Quit. ' + err.message
  })

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