58 typedef std::unique_ptr<packet_stream>
pointer;
78 iConnection(aIoTask, *this, aSecure, aProtocolFamily)
82 iConnection(aIoTask, *this, aHostName, aPort, aSecure, aProtocolFamily)
94 bool open(
const std::string& aRemoteHostName,
unsigned short aRemotePort,
bool aSecure =
false,
protocol_family aProtocolFamily =
IPv4)
96 return iConnection.open(aRemoteHostName, aRemotePort, aSecure, aProtocolFamily);
100 return iConnection.opened();
104 remove_all_packets();
109 iSendQueue.push_back(std::make_unique<packet_type>(aPacket));
110 iConnection.send_packet(*iSendQueue.back(), aHighPriority);
114 return iConnection.connected();
118 return iConnection.closed();
122 return iConnection.has_error();
126 return iConnection.error().message();
130 return iConnection.error().value();
142 return iSendQueue.empty();
152 void handle_connection_established()
override
154 ConnectionEstablished.trigger();
156 void handle_connection_failure(
const boost::system::error_code& aError)
override
158 ConnectionFailure.trigger(aError);
163 PacketSent.trigger(*sentPacket);
167 PacketArrived.trigger(
static_cast<const packet_type&
>(aPacket));
169 void handle_transfer_failure(
const generic_packet_type& aPacket,
const boost::system::error_code& aError)
override
172 TransferFailure.trigger(aError);
174 void handle_connection_closed()
override
176 ConnectionClosed.trigger();
181 for (
auto i = iSendQueue.begin(); i != iSendQueue.end(); ++i)
182 if (&**i == &aPacket)
184 removedPacket = std::move(*i);
186 return removedPacket;
188 return removedPacket;
190 void remove_all_packets()