31 #include <boost/asio.hpp> 32 #include <boost/enable_shared_from_this.hpp> 33 #include <boost/noncopyable.hpp> 39 class ProtocolMessage;
40 class ProtocolMessageWindow;
44 :
private boost::noncopyable,
45 public boost::enable_shared_from_this<IProtocol>
51 virtual void Send(
const ModuleMessage& msg) = 0;
53 virtual void ReceiveACK(
const ProtocolMessage& msg) = 0;
55 virtual bool Receive(
const ProtocolMessage& msg) = 0;
59 virtual void SendACK(
const ProtocolMessage& msg) = 0;
61 virtual void Stop() = 0;
69 boost::asio::ip::udp::socket&
GetSocket();
78 IProtocol(std::string uuid, boost::asio::ip::udp::endpoint endpoint);
82 virtual void Write(ProtocolMessageWindow& msg);
A connection protocol.
Definition: IProtocol.hpp:43
std::string GetUUID() const
Gets the uuid:
Definition: IProtocol.cpp:129
boost::asio::ip::udp::socket & GetSocket()
Get a socket connected to a single peer DGI.
virtual void OnReceive()=0
Peforms an actions after finishing looking through a sliding window.
IProtocol(std::string uuid, boost::asio::ip::udp::endpoint endpoint)
Initializes the protocol with the underlying connection.
Definition: IProtocol.cpp:48
virtual ~IProtocol()
Destroy all humans.
Definition: IProtocol.hpp:49
bool m_stopped
Tracker for the stoppedness of the connection.
Definition: IProtocol.hpp:91
virtual void Stop()=0
Handles Stopping the timers etc.
virtual void ChangePhase(bool)
Handles the change phase even.
Definition: IProtocol.hpp:63
virtual void SendACK(const ProtocolMessage &msg)=0
Handles Writing an ack for the input message to the channel.
virtual bool Receive(const ProtocolMessage &msg)=0
Function that determines if a message should dispatched.
int m_reliability
The reliability of the connection (FOR -DCUSTOMNETWORK)
Definition: IProtocol.hpp:94
virtual void Send(const ModuleMessage &msg)=0
Public write to channel function.
void SetReliability(int r)
Set the connection reliability for DCUSTOMNETWORK.
Definition: IProtocol.cpp:144
General FREEDM Namespace.
Definition: CBroker.cpp:53
void SetStopped(bool v)
Handles setting the stopped variable.
Definition: IProtocol.hpp:67
int GetReliability() const
Get the connection reliability for DCUSTOMNETWORK.
Definition: IProtocol.cpp:158
virtual void WriteCallback(const boost::system::error_code &)
Callback for when a write completes.
Definition: IProtocol.hpp:80
boost::asio::ip::udp::endpoint m_endpoint
Datagram socket connected to a single peer DGI.
Definition: IProtocol.hpp:85
virtual void ReceiveACK(const ProtocolMessage &msg)=0
Public facing function that handles marking ACKS.
bool GetStopped()
Handles checking to see if the connection is stopped.
Definition: IProtocol.hpp:65
std::string m_uuid
The UUID of the remote endpoint for the connection.
Definition: IProtocol.hpp:88
virtual void Write(ProtocolMessageWindow &msg)
Handles writing the message to the underlying connection.
Definition: IProtocol.cpp:74