-
Notifications
You must be signed in to change notification settings - Fork 5
/
AsioSocketConnection.hpp
66 lines (53 loc) · 1.81 KB
/
AsioSocketConnection.hpp
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
/*
AsioQuickfix (c) by Michiel van Slobbe
AsioQuickfix is licensed under a
Creative Commons Attribution-ShareAlike 3.0 Unported License.
You should have received a copy of the license along with this
work. If not, see <http://creativecommons.org/licenses/by-sa/3.0/>.
*/
#ifndef __ASIO_SOCKET_CONNECTION_HPP
#define __ASIO_SOCKET_CONNECTION_HPP
#include <boost/array.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/bind.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/noncopyable.hpp>
#include <boost/shared_ptr.hpp>
#include "quickfix/Session.h"
#include "quickfix/Parser.h"
#define INCOMING_BUFFER_SIZE 8192
#define OUTGOING_BUFFER_SIZE 8192
namespace FIX
{
class AsioSocketConnection;
typedef boost::shared_ptr < AsioSocketConnection > AsioSocketConnection_ptr;
class AsioSocketConnection : private boost::noncopyable,
public Responder
{
public:
AsioSocketConnection ( boost::shared_ptr < boost::asio::ip::tcp::socket > const & socket,
SessionID const & sessionID,
Session * session );
~AsioSocketConnection();
virtual bool send( const std::string& );
virtual void disconnect();
private:
boost::shared_ptr < boost::asio::ip::tcp::socket > m_socket;
SessionID m_session_id;
Session * m_session;
Parser m_parser;
boost::array<char, INCOMING_BUFFER_SIZE> m_incoming_buffer;
boost::array<char, OUTGOING_BUFFER_SIZE> m_outgoing_buffer;
std::vector<char> m_queued_outgoing_buffer;
bool m_sending;
void StartSendAsync();
void StartSendAsync( char const * buf, size_t len );
void StartReadAsync();
void AsyncReadSocket( boost::system::error_code const & error_code,
size_t len );
void AsyncSentSocket( boost::system::error_code const & error_code,
size_t len );
};
}
#endif