Nagram/TMessagesProj/jni/tgnet/Request.h

81 lines
2.1 KiB
C
Raw Normal View History

2015-09-24 20:52:02 +00:00
/*
2018-07-30 02:07:02 +00:00
* This is the source code of tgnet library v. 1.1
2015-09-24 20:52:02 +00: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 02:07:02 +00:00
* Copyright Nikolai Kudashov, 2015-2018.
2015-09-24 20:52:02 +00:00
*/
#ifndef REQUEST_H
#define REQUEST_H
#include <stdint.h>
#include <vector>
#include <bits/unique_ptr.h>
#include "Defines.h"
#ifdef ANDROID
#include <jni.h>
#endif
class TLObject;
class TL_error;
2018-07-30 02:07:02 +00:00
class Datacenter;
2015-09-24 20:52:02 +00:00
class Request {
public:
2018-07-30 02:07:02 +00: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 20:52:02 +00:00
~Request();
int64_t messageId = 0;
int32_t messageSeqNo = 0;
uint32_t datacenterId = 0;
uint32_t connectionToken = 0;
2018-07-30 02:07:02 +00:00
int32_t requestToken = 0;
2015-09-24 20:52:02 +00:00
uint32_t retryCount = 0;
bool failedBySalt = false;
2015-11-26 21:04:02 +00:00
int32_t failedByFloodWait = 0;
2015-09-24 20:52:02 +00:00
ConnectionType connectionType;
uint32_t requestFlags;
bool completed = false;
bool cancelled = false;
bool isInitRequest = false;
2018-07-30 02:07:02 +00:00
bool isInitMediaRequest = false;
2017-03-30 23:58:05 +00:00
uint8_t dataType = 0;
2015-09-24 20:52:02 +00:00
int32_t serializedLength = 0;
int32_t startTime = 0;
2018-07-30 02:07:02 +00:00
int64_t startTimeMillis = 0;
2015-09-24 20:52:02 +00:00
int32_t minStartTime = 0;
int32_t lastResendTime = 0;
2018-07-30 02:07:02 +00:00
int32_t instanceNum = 0;
2015-09-24 20:52:02 +00:00
uint32_t serverFailureCount = 0;
TLObject *rawRequest;
std::unique_ptr<TLObject> rpcRequest;
onCompleteFunc onCompleteRequestCallback;
onQuickAckFunc onQuickAckCallback;
2017-07-08 16:32:04 +00:00
onWriteToSocketFunc onWriteToSocketCallback;
2015-09-24 20:52:02 +00:00
void addRespondMessageId(int64_t id);
bool respondsToMessageId(int64_t id);
void clear(bool time);
2017-03-30 23:58:05 +00:00
void onComplete(TLObject *result, TL_error *error, int32_t networkType);
2015-09-24 20:52:02 +00:00
void onQuickAck();
2017-07-08 16:32:04 +00:00
void onWriteToSocket();
2018-07-30 02:07:02 +00:00
bool isMediaRequest();
bool hasInitFlag();
bool needInitRequest(Datacenter *datacenter, uint32_t currentVersion);
2015-09-24 20:52:02 +00:00
TLObject *getRpcRequest();
#ifdef ANDROID
jobject ptr1 = nullptr;
jobject ptr2 = nullptr;
2017-07-08 16:32:04 +00:00
jobject ptr3 = nullptr;
2015-09-24 20:52:02 +00:00
#endif
private:
std::vector<int64_t> respondsToMessageIds;
};
#endif