| 6 |
| * Copyright Nikolai Kudashov, 2015-2018. |
| 7 | */ |
| 8 |
| 9 | #ifndef REQUEST_H |
| 10 | #define REQUEST_H |
| 11 |
| 12 | #include <stdint.h> |
| 13 | #include <vector> |
| 14 | #include "Defines.h" |
| 15 |
| 16 | #ifdef ANDROID |
| 17 | #include <jni.h> |
| 18 | #endif |
| 19 |
| 20 | class TLObject; |
| 21 | class TL_error; |
| 22 | class Datacenter; |
| 23 |
| 24 | class Request { |
| 25 |
| 26 | public: |
| 27 | Request(int32_t instance, int32_t token, ConnectionType type, uint32_t flags, uint32_t datacenter, onCompleteFunc completeFunc, onQuickAckFunc quickAckFunc, onWriteToSocketFunc writeToSocketFunc, onRequestClearFunc onClearFunc); |
| 28 | ~Request(); |
| 29 |
| 30 | int64_t messageId = 0; |
| 31 | int32_t messageSeqNo = 0; |
| 32 | uint32_t datacenterId = 0; |
| 33 | uint32_t connectionToken = 0; |
| 34 | int32_t requestToken = 0; |
| 35 | uint32_t retryCount = 0; |
| 36 | bool failedBySalt = false; |
| 37 | int32_t failedByFloodWait = 0; |
| 38 | bool awaitingIntegrityCheck = false; |
| 39 | bool awaitingCaptchaCheck = false; |
| 40 | bool premiumFloodWait = false; |
| 41 | ConnectionType connectionType; |
| 42 | uint32_t requestFlags; |
| 43 | bool completedSent = false; |
| 44 | bool completed = false; |
| 45 | bool cancelled = false; |
| 46 | bool isInitRequest = false; |
| 47 | bool isInitMediaRequest = false; |
| 48 | uint8_t dataType = 0; |
| 49 | int32_t serializedLength = 0; |
| 50 | int32_t startTime = 0; |
| 51 | int64_t startTimeMillis = 0; |
| 52 | int32_t minStartTime = 0; |
| 53 | int32_t lastResendTime = 0; |
| 54 | bool isResending = false; |
| 55 | int32_t instanceNum = 0; |
| 56 | uint32_t serverFailureCount = 0; |
| 57 | TLObject *rawRequest; |
| 58 | std::unique_ptr<TLObject> rpcRequest; |
| 59 | onCompleteFunc onCompleteRequestCallback; |
| 60 | onQuickAckFunc onQuickAckCallback; |
| 61 | onWriteToSocketFunc onWriteToSocketCallback; |
| 62 | bool disableClearCallback = false; |
| 63 | bool doNotClearOnDrop = false; |
| 64 | int32_t clearAfter = 0; |
| 65 | onRequestClearFunc onRequestClearCallback; |
| 66 |
| 67 | void addRespondMessageId(int64_t id); |
| 68 | bool respondsToMessageId(int64_t id); |
| 69 | void clear(bool time); |
| 70 | void onComplete(TLObject *result, TL_error *error, int32_t networkType, int64_t responseTime, int64_t msg_id, int32_t dcId); |
| 71 | void onQuickAck(); |
| 72 | void onWriteToSocket(); |
| 73 | bool isMediaRequest(); |
| 74 | bool isCancelRequest(); |
| 75 | bool hasInitFlag(); |
| 76 | bool needInitRequest(Datacenter *datacenter, uint32_t currentVersion); |
| 77 | TLObject *getRpcRequest(); |
| 78 |
| 79 | private: |
| 80 | std::vector<int64_t> respondsToMessageIds; |
| 81 | }; |
| 82 |
| 83 | #endif |
| 84 |