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 CONNECTIONSESSION_H
|
|
|
|
#define CONNECTIONSESSION_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <vector>
|
|
|
|
#include "Defines.h"
|
|
|
|
|
|
|
|
class ConnectionSession {
|
|
|
|
|
|
|
|
public:
|
2018-07-30 02:07:02 +00:00
|
|
|
ConnectionSession(int32_t instance);
|
2015-09-24 20:52:02 +00:00
|
|
|
void recreateSession();
|
|
|
|
void genereateNewSessionId();
|
|
|
|
void setSessionId(int64_t id);
|
2018-07-30 02:07:02 +00:00
|
|
|
int64_t getSessionId();
|
2015-09-24 20:52:02 +00:00
|
|
|
uint32_t generateMessageSeqNo(bool increment);
|
2019-01-23 17:03:33 +00:00
|
|
|
int32_t isMessageIdProcessed(int64_t messageId);
|
2015-09-24 20:52:02 +00: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 02:07:02 +00:00
|
|
|
int32_t instanceNum;
|
2015-09-24 20:52:02 +00:00
|
|
|
int64_t sessionId;
|
|
|
|
uint32_t nextSeqNo = 0;
|
2017-03-30 23:58:05 +00:00
|
|
|
int64_t minProcessedMessageId = 0;
|
2015-09-24 20:52:02 +00:00
|
|
|
|
|
|
|
std::vector<int64_t> processedMessageIds;
|
|
|
|
std::vector<int64_t> messagesIdsForConfirmation;
|
|
|
|
std::vector<int64_t> processedSessionChanges;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|