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

46 lines
1.2 KiB
C
Raw 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 CONNECTIONSESSION_H
#define CONNECTIONSESSION_H
#include <stdint.h>
#include <vector>
#include "Defines.h"
class ConnectionSession {
public:
2018-07-30 04:07:02 +02:00
ConnectionSession(int32_t instance);
2015-09-24 22:52:02 +02:00
void recreateSession();
void genereateNewSessionId();
void setSessionId(int64_t id);
2018-07-30 04:07:02 +02:00
int64_t getSessionId();
2015-09-24 22:52:02 +02:00
uint32_t generateMessageSeqNo(bool increment);
2019-01-23 18:03:33 +01:00
int32_t isMessageIdProcessed(int64_t messageId);
2015-09-24 22:52:02 +02:00
void addProcessedMessageId(int64_t messageId);
bool hasMessagesToConfirm();
void addMessageToConfirm(int64_t messageId);
NetworkMessage *generateConfirmationRequest();
bool isSessionProcessed(int64_t sessionId);
void addProcessedSession(int64_t sessionId);
private:
2018-07-30 04:07:02 +02:00
int32_t instanceNum;
2015-09-24 22:52:02 +02:00
int64_t sessionId;
uint32_t nextSeqNo = 0;
2017-03-31 01:58:05 +02:00
int64_t minProcessedMessageId = 0;
2015-09-24 22:52:02 +02:00
std::vector<int64_t> processedMessageIds;
std::vector<int64_t> messagesIdsForConfirmation;
std::vector<int64_t> processedSessionChanges;
};
#endif