aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/contentscript.js
diff options
context:
space:
mode:
authorFrankie <frankie.pangilinan@consensys.net>2016-10-14 06:17:30 +0800
committerFrankie <frankie.pangilinan@consensys.net>2016-10-14 06:17:30 +0800
commitb200f74d5f414408881fc56b44dc3c7c7bbb7996 (patch)
tree84d0dd8585b1fe6bd252a655f8e289fc3bee271e /app/scripts/contentscript.js
parentc400f7c0f6bff13400eedcd80fdc83e572eb42a8 (diff)
parent8d5b2478e3aa939cb4b0a58b20b199cded62769e (diff)
downloadtangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.tar
tangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.tar.gz
tangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.tar.bz2
tangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.tar.lz
tangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.tar.xz
tangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.tar.zst
tangerine-wallet-browser-b200f74d5f414408881fc56b44dc3c7c7bbb7996.zip
Merge branch 'master' into i#495CustomGasField
Diffstat (limited to 'app/scripts/contentscript.js')
-rw-r--r--app/scripts/contentscript.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/app/scripts/contentscript.js b/app/scripts/contentscript.js
index b3a560c88..3ad145e3e 100644
--- a/app/scripts/contentscript.js
+++ b/app/scripts/contentscript.js
@@ -1,4 +1,5 @@
const LocalMessageDuplexStream = require('post-message-stream')
+const PongStream = require('ping-pong-stream/pong')
const PortStream = require('./lib/port-stream.js')
const ObjectMultiplex = require('./lib/obj-multiplex')
const extension = require('./lib/extension')
@@ -51,17 +52,20 @@ function setupStreams(){
// forward communication plugin->inpage
pageStream.pipe(pluginStream).pipe(pageStream)
- // connect contentscript->inpage reload stream
+ // setup local multistream channels
var mx = ObjectMultiplex()
mx.on('error', console.error)
- mx.pipe(pageStream)
- var reloadStream = mx.createStream('reload')
- reloadStream.on('error', console.error)
+ mx.pipe(pageStream).pipe(mx)
+
+ // connect ping stream
+ var pongStream = new PongStream({ objectMode: true })
+ pongStream.pipe(mx.createStream('pingpong')).pipe(pongStream)
+
+ // ignore unused channels (handled by background)
+ mx.ignoreStream('provider')
+ mx.ignoreStream('publicConfig')
+ mx.ignoreStream('reload')
- // if we lose connection with the plugin, trigger tab refresh
- pluginStream.on('close', function () {
- reloadStream.write({ method: 'reset' })
- })
}
function shouldInjectWeb3(){