FREEDM DGI
CConnection.hpp
Go to the documentation of this file.
1 
24 #ifndef CCONNECTION_HPP
25 #define CCONNECTION_HPP
26 
27 #include "CProtocolSR.hpp"
28 #include "CDispatcher.hpp"
29 #include "SRemoteHost.hpp"
30 
31 #include <memory>
32 
33 #include <boost/noncopyable.hpp>
34 
35 namespace google {
36  namespace protobuf {
37 
38 class Message;
39 
40  }
41 }
42 
43 namespace freedm {
44  namespace broker {
45 
46 class IProtocol;
47 
50  : virtual std::runtime_error
51 {
52  explicit EConnectionError(const std::string& what)
53  : std::runtime_error(what) { }
54 };
55 
58  : private boost::noncopyable
59 {
60 
61 public:
62  typedef boost::shared_ptr<CConnection> ConnectionPtr;
63 
65  CConnection(std::string uuid, boost::asio::ip::udp::endpoint endpoint);
66 
68  ~CConnection();
69 
71  void Stop();
72 
74  bool GetStopped();
75 
77  void Send(const ModuleMessage& msg);
78 
80  void ReceiveACK(const ProtocolMessage& msg);
81 
83  bool Receive(const ProtocolMessage& msg);
84 
86  void OnReceive();
87 
89  void ChangePhase(bool newround);
90 
92  std::string GetUUID() const;
93 
95  void SetReliability(int r);
96 
98  int GetReliability() const;
99 private:
100 
102  boost::shared_ptr<IProtocol> m_protocol;
103 };
104 
105 typedef boost::shared_ptr<CConnection> ConnectionPtr;
106 
107  } // namespace broker
108 } // namespace freedm
109 
110 #endif // CCONNECTION_HPP
Used for errors communicating with peers.
Definition: CConnection.hpp:49
boost::shared_ptr< CConnection > ConnectionPtr
Definition: CConnection.hpp:105
STL namespace.
Represents a single outgoing connection to a client.
Definition: CConnection.hpp:57
boost::shared_ptr< IProtocol > m_protocol
The network protocol to use for sending/receiving messages.
Definition: CConnection.hpp:102
EConnectionError(const std::string &what)
Definition: CConnection.hpp:52
General FREEDM Namespace.
Definition: CBroker.cpp:53
boost::shared_ptr< CConnection > ConnectionPtr
Definition: CConnection.hpp:62
Definition: CConnection.hpp:35