forked from rutice/NicoJK
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathJKTransfer.h
37 lines (35 loc) · 1.07 KB
/
JKTransfer.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
#pragma once
#include "Util.h"
#include <thread>
// プロセス間でコメントと投稿を送受信する
class CJKTransfer
{
public:
static const DWORD CHAT_BUFFER_SIZE = 8192;
static const DWORD POST_BUFFER_SIZE = 1024;
// コメントがあるときの書き込み間隔
static const DWORD WRITE_PENDING_MIN = 200;
// コメントがないときヘッダだけを書き込む間隔
static const DWORD WRITE_PENDING_MAX = 1000;
CJKTransfer();
~CJKTransfer();
void BeginClose();
void Close();
bool Open(HWND hwnd, UINT msg, bool bEnablePost, DWORD processID);
// コメントを送る
bool SendChat(int jkID, const char *text);
// 投稿を受信する
std::string ProcessRecvPost();
private:
bool CreateWorker(HWND hwnd, UINT msg, bool bEnablePost, DWORD processID);
void WorkerThread(HWND hwnd, UINT msg, bool bEnablePost, DWORD processID);
recursive_mutex_ workerLock_;
std::thread workerThread_;
HANDLE hWorkerEvent_;
bool bWorkerCreated_;
bool bContinueWorker_;
bool bStopWroker_;
int currentJKID_;
std::vector<char> chatBuf_;
std::string postStr_;
};