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:
|
2018-07-30 04:07:02 +02:00
|
|
|
Request(int32_t instance, int32_t token, ConnectionType type, uint32_t flags, uint32_t datacenter, onCompleteFunc completeFunc, onQuickAckFunc quickAckFunc, onWriteToSocketFunc writeToSocketFunc);
|
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;
|
2015-09-24 22:52:02 +02:00
|
|
|
ConnectionType connectionType;
|
|
|
|
uint32_t requestFlags;
|
|
|
|
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;
|
2015-09-24 22:52:02 +02:00
|
|
|
|
|
|
|
void addRespondMessageId(int64_t id);
|
|
|
|
bool respondsToMessageId(int64_t id);
|
|
|
|
void clear(bool time);
|
2022-11-06 02:16:18 +01:00
|
|
|
void onComplete(TLObject *result, TL_error *error, int32_t networkType, int64_t responseTime, int64_t msg_id);
|
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();
|
|
|
|
bool hasInitFlag();
|
|
|
|
bool needInitRequest(Datacenter *datacenter, uint32_t currentVersion);
|
2015-09-24 22:52:02 +02:00
|
|
|
TLObject *getRpcRequest();
|
|
|
|
|
|
|
|
#ifdef ANDROID
|
|
|
|
jobject ptr1 = nullptr;
|
|
|
|
jobject ptr2 = nullptr;
|
2017-07-08 18:32:04 +02:00
|
|
|
jobject ptr3 = nullptr;
|
2015-09-24 22:52:02 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<int64_t> respondsToMessageIds;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|