Comparing version 0.5.17 to 0.5.18-beta.0
@@ -93,3 +93,3 @@ 'use strict'; | ||
_this.releases = []; | ||
_this.requestsTime = {}; | ||
_this.requests = {}; | ||
@@ -145,8 +145,9 @@ // A Map of api name to a promise to it's API ID refresh call | ||
var id = data.id; | ||
var msToRespond = Date.now() - _this2.requestsTime[id]; | ||
delete _this2.requestsTime[id]; | ||
if (msToRespond > expectedResponseMs) { | ||
debugWs('Message received in ' + msToRespond + 'ms, it\'s over the expected response time of ' + expectedResponseMs + 'ms', message.data); | ||
var request = _this2.requests[id]; | ||
if (!request) { | ||
console.error('Steem.onMessage error: unknown request ', id); | ||
return; | ||
} | ||
_this2.emit('message', data, msToRespond); | ||
delete _this2.requests[id]; | ||
_this2.onMessage(data, request); | ||
}); | ||
@@ -223,19 +224,32 @@ | ||
} | ||
}, { | ||
key: 'onMessage', | ||
value: function onMessage(message, request) { | ||
var api = request.api, | ||
data = request.data, | ||
resolve = request.resolve, | ||
reject = request.reject, | ||
start_time = request.start_time; | ||
// waitForSlot() { | ||
// if (this.inFlight < 10) { | ||
// debugEmitters('Less than 10 in-flight messages, moving on'); | ||
// return null; | ||
// } | ||
// | ||
// debugEmitters('More than 10 in-flight messages, waiting'); | ||
// return Promise.delay(100).then(() => { | ||
// if (this.inFlight < 10) { | ||
// debugEmitters('Less than 10 in-flight messages, moving on'); | ||
// return null; | ||
// } | ||
// return this.waitForSlot(); | ||
// }); | ||
// } | ||
console.log('-- Steem.onMessage -->', message.id); | ||
var errorCause = message.error; | ||
if (errorCause) { | ||
var err = new Error( | ||
// eslint-disable-next-line prefer-template | ||
(errorCause.message || 'Failed to complete operation') + ' (see err.payload for the full error payload)'); | ||
err.payload = message; | ||
reject(err); | ||
return; | ||
} | ||
if (api === 'login_api' && data.method === 'login') { | ||
debugApiIds('network_broadcast_api API ID depends on the WS\' session. ' + 'Triggering a refresh...'); | ||
this.getApiIds('network_broadcast_api', true); | ||
} | ||
debugProtocol('Resolved', api, data, '->', message); | ||
this.emit('track-performance', data.method, Date.now() - start_time); | ||
delete this.requests[message.id]; | ||
resolve(message.result); | ||
} | ||
}, { | ||
@@ -271,35 +285,10 @@ key: 'send', | ||
var release = _this4.listenTo(_this4, 'message', function (message, time_taken) { | ||
// We're still seeing old messages | ||
if (message.id !== id) { | ||
debugProtocol('Different message was dropped', message); | ||
return; | ||
} | ||
// this.inFlight -= 1; | ||
release(); | ||
// Our message's response came back | ||
var errorCause = message.error; | ||
if (errorCause) { | ||
var err = new Error( | ||
// eslint-disable-next-line prefer-template | ||
(errorCause.message || 'Failed to complete operation') + ' (see err.payload for the full error payload)'); | ||
err.payload = message; | ||
reject(err); | ||
return; | ||
} | ||
if (api === 'login_api' && data.method === 'login') { | ||
debugApiIds('network_broadcast_api API ID depends on the WS\' session. ' + 'Triggering a refresh...'); | ||
_this4.getApiIds('network_broadcast_api', true); | ||
} | ||
debugProtocol('Resolved', api, data, '->', message); | ||
_this4.emit('track-performance', data.method, time_taken); | ||
resolve(message.result); | ||
}); | ||
debugWs('Sending message', payload); | ||
_this4.requestsTime[id] = Date.now(); | ||
_this4.requests[id] = { | ||
api: api, | ||
data: data, | ||
resolve: resolve, | ||
reject: reject, | ||
start_time: Date.now() | ||
}; | ||
@@ -306,0 +295,0 @@ // this.inFlight += 1; |
{ | ||
"name": "steem", | ||
"version": "0.5.17", | ||
"version": "0.5.18-beta.0", | ||
"description": "Steem.js the JavaScript API for Steem blockchain", | ||
@@ -77,2 +77,2 @@ "main": "index.js", | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11
12927803
9587