Improved parsing repeating responses
This commit is contained in:
parent
c40608e653
commit
c36823070e
@ -797,8 +797,8 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
// console.log('Set lp', this.longPollPending, tsNow());
|
// console.log('Set lp', this.longPollPending, tsNow());
|
||||||
|
|
||||||
this.wrapMtpCall('http_wait', {
|
this.wrapMtpCall('http_wait', {
|
||||||
max_delay: 0,
|
max_delay: 500,
|
||||||
wait_after: 0,
|
wait_after: 150,
|
||||||
max_wait: maxWait
|
max_wait: maxWait
|
||||||
}, {
|
}, {
|
||||||
noResponse: true,
|
noResponse: true,
|
||||||
@ -1035,7 +1035,11 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
|
|
||||||
if (hasApiCall && !hasHttpWait) {
|
if (hasApiCall && !hasHttpWait) {
|
||||||
var serializer = new TLSerialization({mtproto: true});
|
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({
|
messages.push({
|
||||||
msg_id: MtpTimeManager.generateID(),
|
msg_id: MtpTimeManager.generateID(),
|
||||||
seq_no: this.generateSeqNo(),
|
seq_no: this.generateSeqNo(),
|
||||||
@ -1093,6 +1097,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
var self = this;
|
var self = this;
|
||||||
this.sendEncryptedRequest(message).then(function (result) {
|
this.sendEncryptedRequest(message).then(function (result) {
|
||||||
self.toggleOffline(false);
|
self.toggleOffline(false);
|
||||||
|
// console.log('parse for', message);
|
||||||
self.parseResponse(result.data).then(function (response) {
|
self.parseResponse(result.data).then(function (response) {
|
||||||
if (Config.Modes.debug) {
|
if (Config.Modes.debug) {
|
||||||
console.log(dT(), 'Server response', self.dcID, response);
|
console.log(dT(), 'Server response', self.dcID, response);
|
||||||
@ -1283,7 +1288,7 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
result.body = {_: 'parse_error', error: e};
|
result.body = {_: 'parse_error', error: e};
|
||||||
}
|
}
|
||||||
if (this.offset != offset + result.bytes) {
|
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);
|
// console.log(dT(), result);
|
||||||
this.offset = offset + result.bytes;
|
this.offset = offset + result.bytes;
|
||||||
}
|
}
|
||||||
@ -1295,8 +1300,12 @@ angular.module('izhukov.mtproto', ['izhukov.utils'])
|
|||||||
var sentMessage = self.sentMessages[result.req_msg_id],
|
var sentMessage = self.sentMessages[result.req_msg_id],
|
||||||
type = sentMessage && sentMessage.resultType || 'Object';
|
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]');
|
result.result = this.fetchObject(type, field + '[result]');
|
||||||
// console.log(dT(), 'override rpc_result', type, result);
|
// console.log(dT(), 'override rpc_result', sentMessage, type, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user