During the handshake the heartbeat duration the server wants is stored in the connection so that clients can retrieve and use it for error detection
This commit is contained in:
parent
12af6e854a
commit
74a1a17553
|
|
@ -153,6 +153,15 @@ public:
|
|||
return _implementation.channels();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the heartbeat delay used by this connection
|
||||
* @return uint16_t
|
||||
*/
|
||||
uint16_t heartbeat() const
|
||||
{
|
||||
return _implementation.heartbeat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Some classes have access to private properties
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -93,6 +93,12 @@ protected:
|
|||
*/
|
||||
std::queue<OutBuffer> _queue;
|
||||
|
||||
/**
|
||||
* Heartbeat delay
|
||||
* @var uint16_t
|
||||
*/
|
||||
uint16_t _heartbeat = 0;
|
||||
|
||||
/**
|
||||
* Helper method to send the close frame
|
||||
* Return value tells if the connection is still valid
|
||||
|
|
@ -342,6 +348,23 @@ public:
|
|||
return _channels.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Heartbeat delay
|
||||
* @return uint16_t
|
||||
*/
|
||||
uint16_t heartbeat() const
|
||||
{
|
||||
return _heartbeat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the heartbeat delay
|
||||
*/
|
||||
void setHeartbeat(uint16_t heartbeat)
|
||||
{
|
||||
_heartbeat = heartbeat;
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual connection is a friend and can construct this class
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -137,6 +137,9 @@ public:
|
|||
// theoretically it is possible that the connection object gets destructed between sending the messages
|
||||
Monitor monitor(connection);
|
||||
|
||||
// store the heartbeat the server wants
|
||||
connection->setHeartbeat(heartbeat());
|
||||
|
||||
// send it back
|
||||
connection->send(ConnectionTuneOKFrame(channelMax(), frameMax(), heartbeat()));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue