aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-05-06 07:04:43 +0800
committerkumavis <aaron@kumavis.me>2016-05-06 07:04:43 +0800
commitaa2816010dc724e3976dc3e639179221cdce7d66 (patch)
tree11bf4022de245eb8f48668bf7e6f666ba06dbeb5 /app/scripts/lib
parentb863fe16e885e8548f371898532c914a6540ebed (diff)
downloadtangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.tar
tangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.tar.gz
tangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.tar.bz2
tangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.tar.lz
tangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.tar.xz
tangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.tar.zst
tangerine-wallet-browser-aa2816010dc724e3976dc3e639179221cdce7d66.zip
inpage - automatic dapp reload
Diffstat (limited to 'app/scripts/lib')
-rw-r--r--app/scripts/lib/local-message-stream.js8
-rw-r--r--app/scripts/lib/port-stream.js4
-rw-r--r--app/scripts/lib/stream-utils.js1
3 files changed, 9 insertions, 4 deletions
diff --git a/app/scripts/lib/local-message-stream.js b/app/scripts/lib/local-message-stream.js
index 42d193e04..76fedd9df 100644
--- a/app/scripts/lib/local-message-stream.js
+++ b/app/scripts/lib/local-message-stream.js
@@ -23,7 +23,7 @@ function LocalMessageDuplexStream(opts){
LocalMessageDuplexStream.prototype._onMessage = function(event){
var msg = event.data
- // console.log('LocalMessageDuplexStream ('+this._name+') - heard message...')
+ // console.log('LocalMessageDuplexStream ('+this._name+') - heard message...', event)
// validate message
if (event.origin !== location.origin) return //console.log('LocalMessageDuplexStream ('+this._name+') - rejected - (event.origin !== location.origin) ')
if (typeof msg !== 'object') return //console.log('LocalMessageDuplexStream ('+this._name+') - rejected - (typeof msg !== "object") ')
@@ -31,7 +31,11 @@ LocalMessageDuplexStream.prototype._onMessage = function(event){
if (!msg.data) return //console.log('LocalMessageDuplexStream ('+this._name+') - rejected - (!msg.data) ')
// console.log('LocalMessageDuplexStream ('+this._name+') - accepted', msg.data)
// forward message
- this.push(msg.data)
+ try {
+ this.push(msg.data)
+ } catch(err) {
+ this.emit('error', err)
+ }
}
// stream plumbing
diff --git a/app/scripts/lib/port-stream.js b/app/scripts/lib/port-stream.js
index a6c974d6d..2644741fc 100644
--- a/app/scripts/lib/port-stream.js
+++ b/app/scripts/lib/port-stream.js
@@ -31,7 +31,8 @@ PortDuplexStream.prototype._onMessage = function(msg){
PortDuplexStream.prototype._onDisconnect = function(){
try {
- this.end()
+ // this.end()
+ this.emit('close')
} catch(err){
this.emit('error', err)
}
@@ -54,6 +55,7 @@ PortDuplexStream.prototype._write = function(msg, encoding, cb){
}
cb()
} catch(err){
+ console.error(err)
// this.emit('error', err)
cb(new Error('PortDuplexStream - disconnected'))
}
diff --git a/app/scripts/lib/stream-utils.js b/app/scripts/lib/stream-utils.js
index fd4417d94..ca245ca9a 100644
--- a/app/scripts/lib/stream-utils.js
+++ b/app/scripts/lib/stream-utils.js
@@ -27,7 +27,6 @@ function setupMultiplex(connectionStream){
connectionStream.pipe(mx).pipe(connectionStream)
mx.on('error', function(err) {
console.error(err)
- // connectionStream.destroy()
})
connectionStream.on('error', function(err) {
console.error(err)