Telegram-Android/TMessagesProj/jni/tgnet/Request.h

83 lines
2.4 KiB
C
Raw Permalink Normal View History

2015-09-24 22:52:02 +02:00
/*
2018-07-30 04:07:02 +02:00
* This is the source code of tgnet library v. 1.1
2015-09-24 22:52:02 +02:00
* It is licensed under GNU GPL v. 2 or later.
* You should have received a copy of the license in this archive (see LICENSE).
*
2018-07-30 04:07:02 +02:00
* Copyright Nikolai Kudashov, 2015-2018.
2015-09-24 22:52:02 +02:00
*/
#ifndef REQUEST_H
#define REQUEST_H
#include <stdint.h>
#include <vector>
#include "Defines.h"
#ifdef ANDROID
#include <jni.h>
#endif
class TLObject;
class TL_error;
2018-07-30 04:07:02 +02:00
class Datacenter;
2015-09-24 22:52:02 +02:00
class Request {
public:
2024-03-08 15:32:16 +01:00
Request(int32_t instance, int32_t token, ConnectionType type, uint32_t flags, uint32_t datacenter, onCompleteFunc completeFunc, onQuickAckFunc quickAckFunc, onWriteToSocketFunc writeToSocketFunc, onRequestClearFunc onClearFunc);
2015-09-24 22:52:02 +02:00
~Request();
int64_t messageId = 0;
int32_t messageSeqNo = 0;
uint32_t datacenterId = 0;
uint32_t connectionToken = 0;
2018-07-30 04:07:02 +02:00
int32_t requestToken = 0;
2015-09-24 22:52:02 +02:00
uint32_t retryCount = 0;
bool failedBySalt = false;
2015-11-26 22:04:02 +01:00
int32_t failedByFloodWait = 0;
2024-06-03 08:21:03 +02:00
bool awaitingIntegrityCheck = false;
2024-03-31 21:10:51 +02:00
bool premiumFloodWait = false;
2015-09-24 22:52:02 +02:00
ConnectionType connectionType;
uint32_t requestFlags;
2024-03-08 15:32:16 +01:00
bool completedSent = false;
2015-09-24 22:52:02 +02:00
bool completed = false;
bool cancelled = false;
bool isInitRequest = false;
2018-07-30 04:07:02 +02:00
bool isInitMediaRequest = false;
2017-03-31 01:58:05 +02:00
uint8_t dataType = 0;
2015-09-24 22:52:02 +02:00
int32_t serializedLength = 0;
int32_t startTime = 0;
2018-07-30 04:07:02 +02:00
int64_t startTimeMillis = 0;
2015-09-24 22:52:02 +02:00
int32_t minStartTime = 0;
int32_t lastResendTime = 0;
2021-07-15 16:24:57 +02:00
bool isResending = false;
2018-07-30 04:07:02 +02:00
int32_t instanceNum = 0;
2015-09-24 22:52:02 +02:00
uint32_t serverFailureCount = 0;
TLObject *rawRequest;
std::unique_ptr<TLObject> rpcRequest;
onCompleteFunc onCompleteRequestCallback;
onQuickAckFunc onQuickAckCallback;
2017-07-08 18:32:04 +02:00
onWriteToSocketFunc onWriteToSocketCallback;
2024-03-08 15:32:16 +01:00
bool disableClearCallback = false;
bool doNotClearOnDrop = false;
int32_t clearAfter = 0;
onRequestClearFunc onRequestClearCallback;
2015-09-24 22:52:02 +02:00
void addRespondMessageId(int64_t id);
bool respondsToMessageId(int64_t id);
void clear(bool time);
2024-10-17 22:04:16 +02:00
void onComplete(TLObject *result, TL_error *error, int32_t networkType, int64_t responseTime, int64_t msg_id, int32_t dcId);
2015-09-24 22:52:02 +02:00
void onQuickAck();
2017-07-08 18:32:04 +02:00
void onWriteToSocket();
2018-07-30 04:07:02 +02:00
bool isMediaRequest();
2023-10-28 22:52:06 +02:00
bool isCancelRequest();
2018-07-30 04:07:02 +02:00
bool hasInitFlag();
bool needInitRequest(Datacenter *datacenter, uint32_t currentVersion);
2015-09-24 22:52:02 +02:00
TLObject *getRpcRequest();
private:
std::vector<int64_t> respondsToMessageIds;
};
#endif