Improved parsing repeating responses

This commit is contained in:
Igor Zhukov 2015-10-23 01:12:44 +02:00
parent c40608e653
commit c36823070e

View File

@ -797,8 +797,8 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
// console.log('Set lp', this.longPollPending, tsNow());
this.wrapMtpCall('http_wait', {
max_delay: 0,
wait_after: 0,
max_delay: 500,
wait_after: 150,
max_wait: maxWait
}, {
noResponse: true,
@ -1035,7 +1035,11 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
if (hasApiCall && !hasHttpWait) {
var serializer = new TLSerialization({mtproto: true});
serializer.storeMethod('http_wait', {max_delay: 0, wait_after: 0, max_wait: 1000});
serializer.storeMethod('http_wait', {
max_delay: 500,
wait_after: 150,
max_wait: 3000
});
messages.push({
msg_id: MtpTimeManager.generateID(),
seq_no: this.generateSeqNo(),
@ -1093,6 +1097,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var self = this;
this.sendEncryptedRequest(message).then(function (result) {
self.toggleOffline(false);
// console.log('parse for', message);
self.parseResponse(result.data).then(function (response) {
if (Config.Modes.debug) {
console.log(dT(), 'Server response', self.dcID, response);
@ -1283,7 +1288,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
result.body = {_: 'parse_error', error: e};
}
if (this.offset != offset + result.bytes) {
console.warn(dT(), 'set offset', this.offset, offset, result.bytes);
// console.warn(dT(), 'set offset', this.offset, offset, result.bytes);
// console.log(dT(), result);
this.offset = offset + result.bytes;
}
@ -1295,8 +1300,12 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
var sentMessage = self.sentMessages[result.req_msg_id],
type = sentMessage && sentMessage.resultType || 'Object';
if (result.req_msg_id && !sentMessage) {
console.warn(dT(), 'Result for unknown message', result);
return;
}
result.result = this.fetchObject(type, field + '[result]');
// console.log(dT(), 'override rpc_result', type, result);
// console.log(dT(), 'override rpc_result', sentMessage, type, result);
}
}
};