added channel::usable() to replace channel::connected()
This commit is contained in:
parent
6432ce2ec1
commit
888dc8c40b
|
|
@ -125,12 +125,23 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the channel connected?
|
* Is the channel usable / not yet closed?
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool connected()
|
bool usable() const
|
||||||
{
|
{
|
||||||
return _implementation->connected();
|
return _implementation->usable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the channel connected?
|
||||||
|
* This method is deprecated: use Channel::usable()
|
||||||
|
* @return bool
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
bool connected() const
|
||||||
|
{
|
||||||
|
return usable();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -251,10 +251,10 @@ public:
|
||||||
Deferred &resume();
|
Deferred &resume();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the channel connected?
|
* Is the channel usable / not yet closed?
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
bool connected()
|
bool usable() const
|
||||||
{
|
{
|
||||||
return _state == state_connected || _state == state_ready;
|
return _state == state_connected || _state == state_ready;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ void ChannelImpl::onError(const ErrorCallback &callback)
|
||||||
// store callback
|
// store callback
|
||||||
_errorCallback = callback;
|
_errorCallback = callback;
|
||||||
|
|
||||||
// if the channel is connected, all is ok
|
// if the channel is usable, all is ok
|
||||||
if (connected()) return;
|
if (usable()) return;
|
||||||
|
|
||||||
// is the channel closing down?
|
// is the channel closing down?
|
||||||
if (_state == state_closing) return callback("Channel is closing down");
|
if (_state == state_closing) return callback("Channel is closing down");
|
||||||
|
|
@ -246,8 +246,8 @@ Deferred &ChannelImpl::rollbackTransaction()
|
||||||
*/
|
*/
|
||||||
Deferred &ChannelImpl::close()
|
Deferred &ChannelImpl::close()
|
||||||
{
|
{
|
||||||
// this is completely pointless if not connected
|
// this is completely pointless if already closed
|
||||||
if (!connected()) return push(std::make_shared<Deferred>(_state == state_closing));
|
if (!usable()) return push(std::make_shared<Deferred>(_state == state_closing));
|
||||||
|
|
||||||
// send a channel close frame
|
// send a channel close frame
|
||||||
auto &handler = push(ChannelCloseFrame(_id));
|
auto &handler = push(ChannelCloseFrame(_id));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue