-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathWinFrameSession.h
60 lines (48 loc) · 1.15 KB
/
WinFrameSession.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
#pragma once
#include "DnstapException.h"
#include <functional>
#include <memory>
namespace visor::input::dnstap {
template <typename C>
class FrameSessionData
{
public:
using on_data_frame_cb_t = std::function<void(const void *data, std::size_t size)>;
enum class FrameState {
New,
Ready,
Running,
Finishing
};
private:
std::shared_ptr<C> _client_h;
std::string _content_type;
using binary = std::basic_string<uint8_t>;
binary _buffer;
bool _is_bidir{false};
on_data_frame_cb_t _on_data_frame_cb;
FrameState _state{FrameState::New};
public:
FrameSessionData(
std::shared_ptr<C> client,
const std::string &content_type,
on_data_frame_cb_t on_data_frame)
: _client_h{client}
, _content_type{content_type}
, _on_data_frame_cb{std::move(on_data_frame)}
{
}
void receive_socket_data(const uint8_t[], std::size_t)
{
throw DnstapException("Dnstap not supported on Windows OS");
}
const FrameState &state() const
{
return _state;
}
bool is_bidir() const
{
return _is_bidir;
}
};
}