Add sendToHost method

This commit is contained in:
Cheng Zhao 2014-12-17 11:09:11 -08:00
parent d46300587a
commit a8f5a4e2d4
5 changed files with 17 additions and 7 deletions

View file

@ -20,3 +20,10 @@ the `channel` event of `ipc` module, and returns by setting `event.returnValue`.
**Note:** Usually developers should never use this API, since sending
synchronous message would block the whole web page.
## ipc.sendToHost(channel[, args...])
Like `ipc.send` but the message will be sent to the host page instead of the
browser process.
This is mainly used by the page in `<webview>` to communicate with host page.

View file

@ -311,10 +311,10 @@ webview.addEventListener('close', function() {
* `channel` String
* `args` Array
Fired when the guest page has sent an asynchronous message to browser process.
Fired when the guest page has sent an asynchronous message to embedder page.
With `send` method and `ipc-message` event you can easily communicate between
guest page and embedder page:
With `sendToHost` method and `ipc-message` event you can easily communicate
between guest page and embedder page:
```javascript
// In embedder page.
@ -329,7 +329,7 @@ webview.send('ping');
// In guest page.
var ipc = require('ipc');
ipc.on('ping', function() {
ipc.send('pong');
ipc.sendToHost('pong');
})
```