(cobra client) ws cobra subscribe resubscribe at latest position after being disconnected

This commit is contained in:
Benjamin Sergeant 2020-03-13 17:30:31 -07:00
parent 9801ebdb36
commit 44f599747e
3 changed files with 13 additions and 4 deletions

View File

@ -1,6 +1,10 @@
# Changelog
All changes to this project will be documented in this file.
## [8.2.5] - 2020-03-13
(cobra client) ws cobra subscribe resubscribe at latest position after being disconnected
## [8.2.4] - 2020-03-13
(cobra client) can subscribe with a position

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "8.2.4"
#define IX_WEBSOCKET_VERSION "8.2.5"

View File

@ -68,8 +68,10 @@ namespace ix
std::thread t(timer);
std::string subscriptionPosition(position);
conn.setEventCallback(
[&conn, &channel, &jsonWriter, &filter, &position, &msgCount, &msgPerSeconds, &quiet, &fluentd](
[&conn, &channel, &jsonWriter, &filter, &subscriptionPosition, &msgCount, &msgPerSeconds, &quiet, &fluentd](
ix::CobraConnectionEventType eventType,
const std::string& errMsg,
const ix::WebSocketHttpHeaders& headers,
@ -87,10 +89,11 @@ namespace ix
else if (eventType == ix::CobraConnection_EventType_Authenticated)
{
spdlog::info("Subscriber authenticated");
spdlog::info("Subscribing to {} at position {}", channel, subscriptionPosition);
conn.subscribe(channel,
filter,
position,
[&jsonWriter, &quiet, &msgPerSeconds, &msgCount, &fluentd](
subscriptionPosition,
[&jsonWriter, &quiet, &msgPerSeconds, &msgCount, &fluentd, &subscriptionPosition](
const Json::Value& msg, const std::string& position) {
if (!quiet)
{
@ -99,6 +102,8 @@ namespace ix
msgPerSeconds++;
msgCount++;
subscriptionPosition = position;
});
}
else if (eventType == ix::CobraConnection_EventType_Subscribed)