forked from dolphin-emu/dolphin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TAPServerConnection.h
48 lines (37 loc) · 1.04 KB
/
TAPServerConnection.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
// Copyright 2020 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <functional>
#include <string>
#include <thread>
#include "Common/Flag.h"
#include "Common/SocketContext.h"
namespace ExpansionInterface
{
class TAPServerConnection
{
public:
using RecvCallback = std::function<void(std::string&&)>;
TAPServerConnection(const std::string& destination, RecvCallback recv_cb,
std::size_t max_frame_size);
bool Activate();
void Deactivate();
bool IsActivated();
bool RecvInit();
void RecvStart();
void RecvStop();
bool SendAndRemoveAllHDLCFrames(std::string* send_buf);
bool SendFrame(const u8* frame, u32 size);
private:
const std::string m_destination;
const RecvCallback m_recv_cb;
const std::size_t m_max_frame_size;
Common::SocketContext m_socket_context;
int m_fd = -1;
std::thread m_read_thread;
Common::Flag m_read_enabled;
Common::Flag m_read_shutdown;
bool StartReadThread();
void ReadThreadHandler();
};
} // namespace ExpansionInterface