diff --git a/include/connection.h b/include/connection.h index 4361346..7e2793c 100644 --- a/include/connection.h +++ b/include/connection.h @@ -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 */ diff --git a/include/connectionimpl.h b/include/connectionimpl.h index 908f6c7..5a6c309 100644 --- a/include/connectionimpl.h +++ b/include/connectionimpl.h @@ -97,6 +97,12 @@ protected: */ std::queue _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 */ diff --git a/src/connectiontuneframe.h b/src/connectiontuneframe.h index eac4b72..7887ab3 100644 --- a/src/connectiontuneframe.h +++ b/src/connectiontuneframe.h @@ -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()));