Last active
March 26, 2016 16:26
-
-
Save KimuraTakaumi/f57c7c01e29cf1cdd981 to your computer and use it in GitHub Desktop.
Electronでプロセス間通信(ipc) RendererProcessからMainProcessへ同期通信
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Hello World!</title> | |
<script type="text/javascript"> | |
var ipc = require('ipc'); | |
// 同期でレンダラープロセスからメインプロセスにメッセージを送信する | |
function synchronousMessage() { | |
console.log("synchronousMessage"); | |
var response = ipc.sendSync('synchronous-message', 'synchronous-message render process.'); | |
console.log("synchronousMessage response : " + response); | |
} | |
</script> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
<button onclick="synchronousMessage()">synchronousMessage</button> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ipc = require('ipc'); | |
// 同期でレンダラープロセスからのメッセージを受信し、メッセージを返信する | |
ipc.on('synchronous-message', function (event, arg) { | |
console.log("synchronous-message arg : " + arg); | |
event.returnValue = 'synchronous-message main process.'; | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment