Merge pull request #47 from keenlogics/Heartbeat
The server heartbeat is stored in Connection
This commit is contained in:
commit
0e5024d38a
|
|
@ -167,6 +167,15 @@ public:
|
||||||
return _implementation.waiting();
|
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
|
* Some classes have access to private properties
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
std::queue<OutBuffer> _queue;
|
std::queue<OutBuffer> _queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Heartbeat delay
|
||||||
|
* @var uint16_t
|
||||||
|
*/
|
||||||
|
uint16_t _heartbeat = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to send the close frame
|
* Helper method to send the close frame
|
||||||
* Return value tells if the connection is still valid
|
* Return value tells if the connection is still valid
|
||||||
|
|
@ -351,6 +357,23 @@ public:
|
||||||
return _channels.size();
|
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
|
* 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
|
// theoretically it is possible that the connection object gets destructed between sending the messages
|
||||||
Monitor monitor(connection);
|
Monitor monitor(connection);
|
||||||
|
|
||||||
|
// store the heartbeat the server wants
|
||||||
|
connection->setHeartbeat(heartbeat());
|
||||||
|
|
||||||
// send it back
|
// send it back
|
||||||
connection->send(ConnectionTuneOKFrame(channelMax(), frameMax(), heartbeat()));
|
connection->send(ConnectionTuneOKFrame(channelMax(), frameMax(), heartbeat()));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue