Skip to content

Commit 0a1079c

Browse files
Add unit-tests for JsonRpcConnection
1 parent be805a8 commit 0a1079c

File tree

4 files changed

+446
-13
lines changed

4 files changed

+446
-13
lines changed

lib/remote/jsonrpcconnection.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ void JsonRpcConnection::SendRawMessage(const String& message)
236236
});
237237
}
238238

239+
void JsonRpcConnection::SetLivenessTimeout(std::chrono::milliseconds timeout)
240+
{
241+
m_LivenessTimeout = timeout;
242+
}
243+
239244
void JsonRpcConnection::SendMessageInternal(const Dictionary::Ptr& message)
240245
{
241246
if (m_ShuttingDown) {
@@ -411,7 +416,7 @@ void JsonRpcConnection::CheckLiveness(boost::asio::yield_context yc)
411416
* leaking the connection. Therefore close it after a timeout.
412417
*/
413418

414-
m_CheckLivenessTimer.expires_from_now(boost::posix_time::seconds((m_LivenessTimeout / 6).count()));
419+
m_CheckLivenessTimer.expires_from_now(boost::posix_time::milliseconds(m_LivenessTimeout.count() / 6));
415420
m_CheckLivenessTimer.async_wait(yc[ec]);
416421

417422
if (m_ShuttingDown) {

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ set(base_test_SOURCES
122122
remote-configpackageutility.cpp
123123
remote-httpserverconnection.cpp
124124
remote-httpmessage.cpp
125+
remote-jsonrpcconnection.cpp
125126
remote-url.cpp
126127
${base_OBJS}
127128
$<TARGET_OBJECTS:config>

0 commit comments

Comments
 (0)