-
Notifications
You must be signed in to change notification settings - Fork 158
/
PacketSender.h
64 lines (50 loc) · 1.48 KB
/
PacketSender.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// Created by Grishka on 19/03/2019.
//
#ifndef LIBTGVOIP_PACKETSENDER_H
#define LIBTGVOIP_PACKETSENDER_H
#include "VoIPController.h"
#include <functional>
#include <stdint.h>
namespace tgvoip{
class PacketSender{
public:
PacketSender(VoIPController* controller) : controller(controller) {};
virtual ~PacketSender(){};
virtual void PacketAcknowledged(uint32_t seq, double sendTime, double ackTime, uint8_t type, uint32_t size)=0;
virtual void PacketLost(uint32_t seq, uint8_t type, uint32_t size)=0;
protected:
void SendExtra(Buffer& data, unsigned char type){
controller->SendExtra(data, type);
}
void IncrementUnsentStreamPackets(){
controller->unsentStreamPackets++;
}
uint32_t SendPacket(VoIPController::PendingOutgoingPacket pkt){
uint32_t seq=controller->GenerateOutSeq();
pkt.seq=seq;
controller->SendOrEnqueuePacket(std::move(pkt), true, this);
return seq;
}
double GetConnectionInitTime(){
return controller->connectionInitTime;
}
const HistoricBuffer<double, 32>& RTTHistory(){
return controller->rttHistory;
}
MessageThread& GetMessageThread(){
return controller->messageThread;
}
const VoIPController::ProtocolInfo& GetProtocolInfo(){
return controller->protocolInfo;
}
void SendStreamFlags(VoIPController::Stream& stm){
controller->SendStreamFlags(stm);
}
const VoIPController::Config& GetConfig(){
return controller->config;
}
VoIPController* controller;
};
}
#endif //LIBTGVOIP_PACKETSENDER_H