-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTcpSession.h
More file actions
43 lines (38 loc) · 1.14 KB
/
TcpSession.h
File metadata and controls
43 lines (38 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef TOKENWIZARD_SESSION_H
#define TOKENWIZARD_SESSION_H
#include "BaseHeader.h"
#include "HandlerSelector.h"
#include "Worker.h"
extern HandlerSelector handlerSelector;
class TcpSession: public std::enable_shared_from_this<TcpSession> {
tcp::socket mSocket;
enum {
bufferLength = 65536
};
char mData[bufferLength];
void handlePacket(char *bytes, size_t size);
char *writeOffset;
char *readOffset;
size_t currSize = 0;
bool sendDaemonStarted = false;
boost::posix_time::milliseconds mSendInterval;
boost::asio::deadline_timer* timer;
shared_ptr<TcpSession> sendDaemonProtector = nullptr;
void sendDaemonTick();
void readHandler(size_t written);
void read_loop();
public:
Worker* myWorker;
PBuff* currentBuffer;
void sendCurrPBuff();
void replacePBuff();
Packet beginPacket(size_t size);
void endPacket(Packet& p);
void writeStaticPacket(StaticPacket& p);
PBuff* getPacketBuffer(size_t maxSize);
TcpSession(tcp::socket socket, Worker* myWorker);
void startSendDaemon();
void BeginCommunication();
~TcpSession();
};
#endif //TOKENWIZARD_SESSION_H