Repository navigation
Expand file tree
/
Copy paththeService.h
More file actions
71 lines (55 loc) · 2.22 KB
/
Copy paththeService.h
File metadata and controls
71 lines (55 loc) · 2.22 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <winsock2.h>
#include <ws2tcpip.h>
#if !defined(AFX_BG_H__115F4224_5CD5_11D1_ABBA_00A0243D1382__INCLUDED_)
#define AFX_BG_H__115F4224_5CD5_11D1_ABBA_00A0243D1382__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include "StdAfx.h"
#include <atomic>
#include <mutex>
#include <string_view>
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif
class CBgHelperSrv final : public CWinApp {
std::string inf_config_file_path_;
SOCKADDR_IN addr_{};
int tcp_port_ = 7777;
bool wsa_started_ = false;
/* TCP-сокет до ifc_exporter (QML). Используется из нескольких потоков, поэтому
* любое обращение к нему - только под socket_mu_ */
SOCKET socket_ = INVALID_SOCKET;
std::mutex socket_mu_;
HANDLE instance_mutex_ = nullptr; /* защита от второго экземпляра */
HANDLE stop_event_ = nullptr; /* сигнал завершения работы */
HANDLE start_event_ = nullptr; /* запрос немедленного запуска экспорта (START_IMMEDIATELY) */
void close_socket_locked();
void run_pipe_server();
public:
std::atomic<bool> m_connected_to_qml{ false };
std::mutex mu; /* сериализует запуск Revit */
CBgHelperSrv();
bool socket_connect();
void socket_send(std::string_view data);
void close_socket();
/* Запросить немедленный запуск экспорта, обработка - в основном цикле */
void request_start_immediately() const;
/* Запросить завершение работы */
void request_stop() const;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CBgHelperSrv)
BOOL InitInstance() override;
int ExitInstance() override;
//}}AFX_VIRTUAL
// Implementation
//{{AFX_MSG(CBgHelperSrv)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
extern CBgHelperSrv bg_service;
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual Studio will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_BG_H__115F4224_5CD5_11D1_ABBA_00A0243D1382__INCLUDED_)