123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- class MTProtoRequest {
- constructor() {
- this.sent = false;
- this.msgId = 0; //long
- this.sequence = 0;
- this.dirty = false;
- this.sendTime = 0;
- this.confirmReceived = false;
- // These should be overrode
- this.constructorId = 0;
- this.confirmed = false;
- this.responded = false;
- }
- // these should not be overrode
- onSendSuccess() {
- this.sendTime = new Date().getTime();
- this.sent = true;
- }
- onConfirm() {
- this.confirmReceived = true;
- }
- needResend(){
- return this.dirty || (this.confirmed && !this.confirmReceived && new Date().getTime() - this.sendTime > 3000);
- }
- // These should be overrode
- onSend(buffer){
- }
- onResponse(buffer){
- }
- onException(exception){
- }
- }
|