Last active
March 26, 2016 16:26
-
-
Save KimuraTakaumi/f0431eb28d64afb39072 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 asynchronousMessage() { | |
console.log("asynchronousMessage"); | |
ipc.on('asynchronous-reply', function(response) { | |
console.log("asynchronousMessage response : " + response); | |
}); | |
ipc.send('asynchronous-message', 'asynchronous-message render process.'); | |
} | |
</script> | |
</head> | |
<body> | |
<h1>Hello World!</h1> | |
<button onclick="asynchronousMessage()">asynchronousMessage</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('asynchronous-message', function (event, arg) { | |
console.log("asynchronous-message arg : " + arg); | |
event.sender.send('asynchronous-reply', 'asynchronous-message main process.'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment