Merge pull request #47 from keenlogics/Heartbeat

The server heartbeat is stored in Connection
This commit is contained in:
Emiel Bruijntjes 2015-11-01 05:03:02 -05:00
commit 0e5024d38a
3 changed files with 35 additions and 0 deletions

View File

@ -167,6 +167,15 @@ public:
return _implementation.waiting();
}
/**
* 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
*/

View File

@ -97,6 +97,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
@ -351,6 +357,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
*/

View File

@ -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()));