Subversion Repositories HomeAutomation

Rev

Rev 1959 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

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