add support for ConnectionHandler::onAttached() and ConnectionHandler::onDetached()
This commit is contained in:
parent
359eec189f
commit
bb417e89c2
|
|
@ -41,38 +41,6 @@ public:
|
|||
*/
|
||||
virtual ~ConnectionHandler() = default;
|
||||
|
||||
/**
|
||||
* Method that is called immediately after a connection has been attached
|
||||
* to the handler. This method is called right after the connection object
|
||||
* was constructed. You can override this method if you want to initialize
|
||||
* your handler for this specific connection. This is especially useful if
|
||||
* you use your handler to deal with multiple connections, and cannot use
|
||||
* the constructor for initialization.
|
||||
*
|
||||
* @param connection The connection object that was just constructed
|
||||
*/
|
||||
virtual void onAttached(Connection *connection)
|
||||
{
|
||||
// make sure compilers dont complain about unused parameters
|
||||
(void) connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called right before a connection object is destructed.
|
||||
* This is the counterpart of the onAttached() method.
|
||||
*
|
||||
* Wacht out: the connection object that is passed to this method is in
|
||||
* the process of being destructed, which makes it unsafe to call any
|
||||
* methods on it.
|
||||
*
|
||||
* @param connection The connection that is being destructed
|
||||
*/
|
||||
virtual void onDetached(Connection *connection)
|
||||
{
|
||||
// make sure compilers dont complain about unused parameters
|
||||
(void) connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the heartbeat frequency is negotiated
|
||||
* between the server and the client durion connection setup. You
|
||||
|
|
|
|||
|
|
@ -53,26 +53,6 @@ private:
|
|||
*/
|
||||
Connection _connection;
|
||||
|
||||
/**
|
||||
* Method that is called after the connection was constructed
|
||||
* @param connection The connection that was attached to the handler
|
||||
*/
|
||||
virtual void onAttached(Connection *connection) override
|
||||
{
|
||||
// pass on to the handler
|
||||
_handler->onAttached(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the connection is destructed
|
||||
* @param connection The connection that was detached from the handler
|
||||
*/
|
||||
virtual void onDetached(Connection *connection) override
|
||||
{
|
||||
// pass on to the handler
|
||||
_handler->onDetached(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that is called when the heartbeat frequency is negotiated.
|
||||
* @param connection The connection that suggested a heartbeat interval
|
||||
|
|
|
|||
|
|
@ -34,9 +34,6 @@ namespace AMQP {
|
|||
ConnectionImpl::ConnectionImpl(Connection *parent, ConnectionHandler *handler, const Login &login, const std::string &vhost) :
|
||||
_parent(parent), _handler(handler), _login(login), _vhost(vhost)
|
||||
{
|
||||
// tell the handler that it is attached to this connection
|
||||
_handler->onAttached(_parent);
|
||||
|
||||
// we need to send a protocol header
|
||||
send(ProtocolHeaderFrame());
|
||||
}
|
||||
|
|
@ -51,9 +48,6 @@ ConnectionImpl::~ConnectionImpl()
|
|||
|
||||
// invalidate all channels, so they will no longer call methods on this channel object
|
||||
for (auto iter = _channels.begin(); iter != _channels.end(); iter++) iter->second->detach();
|
||||
|
||||
// tell the handler that it is no longer attached to this connection
|
||||
_handler->onDetached(_parent);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue