diff --git a/examples/libev.cpp b/examples/libev.cpp index 43f8bb27..cf9a78d5 100644 --- a/examples/libev.cpp +++ b/examples/libev.cpp @@ -40,6 +40,34 @@ class MyHandler : public AMQP::LibEvHandler { std::cout << "connected" << std::endl; } + + /** + * Method that is called when the TCP connection ends up in a ready + * @param connection The TCP connection + */ + virtual void onReady(AMQP::TcpConnection *connection) override + { + std::cout << "ready" << std::endl; + } + + /** + * Method that is called when the TCP connection is closed + * @param connection The TCP connection + */ + virtual void onClosed(AMQP::TcpConnection *connection) override + { + std::cout << "closed" << std::endl; + } + + /** + * Method that is called when the TCP connection is detached + * @param connection The TCP connection + */ + virtual void onDetached(AMQP::TcpConnection *connection) override + { + std::cout << "detached" << std::endl; + } + public: /** @@ -105,7 +133,7 @@ class MyTimer _channel(channel), _queue(std::move(queue)) { // initialize the libev structure - ev_timer_init(&_timer, callback, 0.005, 0.005); + ev_timer_init(&_timer, callback, 0.005, 1.005); // this object is the data _timer.data = this; @@ -169,6 +197,8 @@ int main() // construct a timer that is going to publish stuff auto *timer = new MyTimer(loop, &channel, name); + + //connection.close(); }); // run the loop diff --git a/include/amqpcpp/linux_tcp/tcpconnection.h b/include/amqpcpp/linux_tcp/tcpconnection.h index d99cdfa4..a01a0860 100644 --- a/include/amqpcpp/linux_tcp/tcpconnection.h +++ b/include/amqpcpp/linux_tcp/tcpconnection.h @@ -22,6 +22,7 @@ namespace AMQP { * Forward declarations */ class TcpState; +class TcpChannel; /** * Class definition @@ -50,6 +51,12 @@ class TcpConnection : * @var Connection */ Connection _connection; + + /** + * The channel may access out _connection + * @friend + */ + friend TcpChannel; /**