blob: bb0db46a5c88eb05811eb104db9b59e1f51c4264 (
plain) (
blame)
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
|
#ifndef _SYNCTCPCONNECTION_H_
#define _SYNCTCPCONNECTION_H_
#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/function.hpp>
#include <boost/asio.hpp>
#include <string>
class SyncTcpConnection
: public boost::enable_shared_from_this<SyncTcpConnection>
{
public:
typedef boost::shared_ptr<SyncTcpConnection> pointer;
typedef boost::asio::ip::tcp proto;
static pointer create(boost::asio::io_service& io_service)
{
return pointer(new SyncTcpConnection(io_service));
};
boost::function<void(SyncTcpConnection *)> onConnect;
proto::socket& socket();
void start();
void Send(std::string message);
private:
SyncTcpConnection(boost::asio::io_service& io_service);
void handle_write(const boost::system::error_code & /*error*/,
size_t /*bytes_transferred*/);
proto::socket socket_;
};
#endif
|