Subversion Repositories HomeAutomation

Rev

Rev 1642 | Rev 1959 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1642 Rev 1898
Line 20... Line 20...
20
 
20
 
21
#ifndef NET_TCPCLIENT_H
21
#ifndef NET_TCPCLIENT_H
22
#define NET_TCPCLIENT_H
22
#define NET_TCPCLIENT_H
23
 
23
 
24
#include "Client.h"
24
#include "Client.h"
-
 
25
 
-
 
26
#include "logging/Logger.h"
25
 
27
 
26
namespace atom {
28
namespace atom {
27
namespace net {
29
namespace net {
28
 
30
 
29
class TcpClient : public Client
31
class TcpClient : public Client
30
{
32
{
31
public:
33
public:
32
    typedef boost::shared_ptr<TcpClient> Pointer;
34
    typedef boost::shared_ptr<TcpClient> Pointer;
33
    typedef  boost::shared_ptr< boost::asio::ip::tcp::acceptor> AcceptorPointer;
35
    typedef  boost::shared_ptr< boost::asio::ip::tcp::acceptor> AcceptorPointer;
34
   
36
   
35
    TcpClient(boost::asio::io_service& io_service, ClientId id, ServerId server_id);
37
    TcpClient(boost::asio::io_service& io_service, ClientId id, ServerId server_id);
36
    virtual ~TcpClient();
38
    virtual ~TcpClient();
37
   
39
   
38
    void Accept(AcceptorPointer acceptor);
40
    void Accept(AcceptorPointer acceptor);
39
    void Connect(std::string address, unsigned int port);
41
    void Connect(std::string address, unsigned int port);
40
    void Send(common::Byteset data);
42
    void Send(common::Byteset data);
41
   
43
   
42
    AcceptorPointer ReleaseAcceptor();
44
    AcceptorPointer ReleaseAcceptor();
43
   
45
   
44
protected:
46
protected:
45
    void Read();
47
    void Read();
46
    void Stop();
48
    void Stop();
47
   
49
   
48
private:
50
private:
-
 
51
    static logging::Logger LOG;
-
 
52
 
49
    boost::asio::ip::tcp::socket socket_;
53
    boost::asio::ip::tcp::socket socket_;
50
    AcceptorPointer acceptor_;
54
    AcceptorPointer acceptor_;
51
   
55
   
52
    void AcceptHandler(const boost::system::error_code& error);
56
    void AcceptHandler(const boost::system::error_code& error);
53
};
57
};