-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClient.h
More file actions
43 lines (38 loc) · 1.03 KB
/
Client.h
File metadata and controls
43 lines (38 loc) · 1.03 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
#pragma once
#include <cstdlib>
#include <deque>
#include <iostream>
#include <thread>
#include <boost/asio.hpp>
#include "Message.h"
#include "Logger.h"
#include <future>
using boost::asio::ip::tcp;
class Client
{
public:
Client( boost::asio::io_service& ioService,tcp::resolver::iterator endpointIterator,std::promise<bool>& promRdy,std::promise<std::string>& promDone );
void Send( const Message& msg );
void Close();
private:
// Server Client Interaction
void Connect( tcp::resolver::iterator endpointIterator );
void ReadHeader();
void ReadBody();
void Write();
Message CreateMessage( std::string content );
public:
// Helper
void RequestUpdateData();
void RequestConnectionData();
//bool ConnectToVM(); // in helper class
//void OnUpdate(); // in helper class
private:
boost::asio::io_service& m_ioService;
tcp::socket m_socket;
Message m_readMsg;
std::deque<Message> m_writeMsgQueue;
//void ( Client::*m_funcptr ) ( std::string,size_t );
std::promise<bool>& m_promRdy;
std::promise<std::string>& m_promDone;
};