Skip to content

Commit 54ec1f4

Browse files
authored
Add timetoken for subscribe_v2_options and fix subscribe v2 types visibility (#229)
feat(cpp): add `timetoken` for `subscribe_v2_options` Add a field that lets the user specify a timetoken for catch-up or `0` to make an initial / handshake subscription. fix: fix types visibility Fix subscribe v2 types visibility when `USE_SUBSCRIBE_V2` not set.
1 parent e14987e commit 54ec1f4

File tree

9 files changed

+52
-15
lines changed

9 files changed

+52
-15
lines changed

.pubnub.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
name: c-core
22
schema: 1
3-
version: "5.2.0"
3+
version: "5.3.0"
44
scm: github.com/pubnub/c-core
55
changelog:
6+
- date: 2025-09-02
7+
version: v5.3.0
8+
changes:
9+
- type: feature
10+
text: "Add a field that lets the user specify a timetoken for catch-up or `0` to make an initial / handshake subscription."
11+
- type: bug
12+
text: "Fix subscribe v2 types visibility when `USE_SUBSCRIBE_V2` not set."
613
- date: 2025-08-19
714
version: v5.2.0
815
changes:
@@ -1019,7 +1026,7 @@ sdks:
10191026
distribution-type: source code
10201027
distribution-repository: GitHub release
10211028
package-name: C-Core
1022-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1029+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
10231030
requires:
10241031
-
10251032
name: "miniz"
@@ -1085,7 +1092,7 @@ sdks:
10851092
distribution-type: source code
10861093
distribution-repository: GitHub release
10871094
package-name: C-Core
1088-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1095+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
10891096
requires:
10901097
-
10911098
name: "miniz"
@@ -1151,7 +1158,7 @@ sdks:
11511158
distribution-type: source code
11521159
distribution-repository: GitHub release
11531160
package-name: C-Core
1154-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1161+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
11551162
requires:
11561163
-
11571164
name: "miniz"
@@ -1213,7 +1220,7 @@ sdks:
12131220
distribution-type: source code
12141221
distribution-repository: GitHub release
12151222
package-name: C-Core
1216-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1223+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
12171224
requires:
12181225
-
12191226
name: "miniz"
@@ -1274,7 +1281,7 @@ sdks:
12741281
distribution-type: source code
12751282
distribution-repository: GitHub release
12761283
package-name: C-Core
1277-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1284+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
12781285
requires:
12791286
-
12801287
name: "miniz"
@@ -1330,7 +1337,7 @@ sdks:
13301337
distribution-type: source code
13311338
distribution-repository: GitHub release
13321339
package-name: C-Core
1333-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1340+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
13341341
requires:
13351342
-
13361343
name: "miniz"
@@ -1383,7 +1390,7 @@ sdks:
13831390
distribution-type: source code
13841391
distribution-repository: GitHub release
13851392
package-name: C-Core
1386-
location: https://github.com/pubnub/c-core/releases/tag/v5.2.0
1393+
location: https://github.com/pubnub/c-core/releases/tag/v5.3.0
13871394
requires:
13881395
-
13891396
name: "miniz"

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## v5.3.0
2+
September 02 2025
3+
4+
#### Added
5+
- Add a field that lets the user specify a timetoken for catch-up or `0` to make an initial / handshake subscription.
6+
7+
#### Fixed
8+
- Fix subscribe v2 types visibility when `USE_SUBSCRIBE_V2` not set.
9+
110
## v5.2.0
211
August 19 2025
312

core/pbauto_heartbeat.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,9 @@ void pbauto_heartbeat_start_timer(pubnub_t const* pb)
759759
}
760760
/*FALLTHRU*/
761761
case PBTT_SUBSCRIBE:
762+
#if PUBNUB_USE_SUBSCRIBE_V2
762763
case PBTT_SUBSCRIBE_V2:
764+
#endif // #if PUBNUB_USE_SUBSCRIBE_V2
763765
start_heartbeat_timer(pb->thumperIndex);
764766
break;
765767
default:
@@ -828,7 +830,9 @@ void pbauto_heartbeat_transaction_ongoing(pubnub_t const* pb)
828830
}
829831
/*FALLTHRU*/
830832
case PBTT_SUBSCRIBE:
833+
#if PUBNUB_USE_SUBSCRIBE_V2
831834
case PBTT_SUBSCRIBE_V2:
835+
#endif // #if PUBNUB_USE_SUBSCRIBE_V2
832836
// Ignore implicit heartbeat if "smart heartbeat" is disabled.
833837
if (!pb->use_smart_heartbeat) return;
834838

core/pbcc_event_engine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ enum pubnub_res pbcc_ee_handle_event(
312312
const size_t count = pbarray_count(invocations);
313313
const pbarray_res merge_rslt = pbarray_merge(ee->invocations, invocations);
314314
if (PBAR_OK != merge_rslt) {
315-
rslt = PBTT_ADD_MEMBERS == merge_rslt
315+
rslt = PBAR_OUT_OF_MEMORY == merge_rslt
316316
? PNR_OUT_OF_MEMORY
317317
: PNR_INVALID_PARAMETERS;
318318
}

core/pubnub_version_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define INC_PUBNUB_VERSION_INTERNAL
44

55

6-
#define PUBNUB_SDK_VERSION "5.2.0"
6+
#define PUBNUB_SDK_VERSION "5.3.0"
77

88

99
#endif /* !defined INC_PUBNUB_VERSION_INTERNAL */

cpp/pubnub_common.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class subscribe_v2_options {
238238
pubnub_subscribe_v2_options d_;
239239
std::string d_chgrp;
240240
std::string d_filter_expr;
241+
std::string d_timetoken;
241242

242243
public:
243244
subscribe_v2_options() { d_ = pubnub_subscribe_v2_defopts(); }
@@ -262,6 +263,17 @@ class subscribe_v2_options {
262263
d_.filter_expr = d_filter_expr.empty() ? 0 : d_filter_expr.c_str();
263264
return *this;
264265
}
266+
subscribe_v2_options& timetoken(std::string const& timetoken)
267+
{
268+
d_timetoken = timetoken;
269+
if (d_timetoken.empty()) {
270+
d_.timetoken[0] = '\0';
271+
} else {
272+
std::strncpy(d_.timetoken, d_timetoken.c_str(), sizeof(d_.timetoken) - 1);
273+
d_.timetoken[d_timetoken.size()] = '\0';
274+
}
275+
return *this;
276+
}
265277
pubnub_subscribe_v2_options data() { return d_; }
266278
};
267279
#endif /* PUBNUB_USE_SUBSCRIBE_V2 */
@@ -1881,14 +1893,14 @@ class context {
18811893

18821894
/// Instructs C-core to use system certificate store.
18831895
/// @see pubnub_ssl_use_system_certificate_store
1884-
int use_system_certificate_store()
1896+
void use_system_certificate_store()
18851897
{
18861898
pubnub_ssl_use_system_certificate_store(d_pb);
18871899
}
18881900

18891901
/// Instructs C-core to not use system certificate store.
18901902
/// @see pubnub_ssl_dont_use_system_certificate_store
1891-
int dont_use_system_certificate_store()
1903+
void dont_use_system_certificate_store()
18921904
{
18931905
pubnub_ssl_dont_use_system_certificate_store(d_pb);
18941906
}

lib/md5/pbmd5.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#if !defined INC_PBMD5
33
#define INC_PBMD5
44

5-
65
/** @file pbmd5.h
76
87
This is the internal "MD5" Message Digest API of the Pubnub client
@@ -75,4 +74,4 @@
7574
MD5_Final((d), &M_ctx); \
7675
} while (0)
7776

78-
#endif /* !defined INC_PBMD5 */
77+
#endif /* !defined INC_PBMD5 */

make/common/targets_cpp_app_openssl.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(TARGET_BUILD_PATH)pubnub_sync_revoke_sample$(APP_EXT): \
2929
$(COMPILER) $(OUT_FLAG)$@ $(COMPILER_FLAGS) $(CPPFLAGS) $(PREREQUISITES) $(LINK_FLAG) $(LDLIBS)
3030

3131
SYNC_CRYPTO_MODULE_SOURCES_ = \
32-
./cpp/samples/pubnub_crypto_module_sample.cpp \
32+
../cpp/samples/pubnub_crypto_module_sample.cpp \
3333
$(SOURCE_FILES) \
3434
$(SYNC_SOURCE_FILES) \
3535
$(PUBNUB_FUTRES_SYNC_SOURCE_FILE)

qt/pubnub_qt.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ void pubnub_qt::stop_auto_heartbeat_before_transaction(pubnub_trans transaction)
256256
switch (transaction) {
257257
case PBTT_HEARTBEAT:
258258
case PBTT_SUBSCRIBE:
259+
#if PUBNUB_USE_SUBSCRIBE_V2
259260
case PBTT_SUBSCRIBE_V2:
261+
#endif // #if PUBNUB_USE_SUBSCRIBE_V2
260262
stop_auto_heartbeat();
261263
break;
262264
default:
@@ -274,7 +276,9 @@ void pubnub_qt::start_auto_heartbeat_timer(pubnub_res pbres)
274276
switch (d_trans) {
275277
case PBTT_HEARTBEAT:
276278
case PBTT_SUBSCRIBE:
279+
#if PUBNUB_USE_SUBSCRIBE_V2
277280
case PBTT_SUBSCRIBE_V2:
281+
#endif // #if PUBNUB_USE_SUBSCRIBE_V2
278282
if (PNR_OK == pbres) {
279283
d_auto_heartbeatTimer->start(d_auto_heartbeat_period_sec * UNIT_IN_MILLI);
280284
}
@@ -640,6 +644,7 @@ pubnub_res pubnub_qt::subscribe(QString const& channel, QString const& channel_g
640644
}
641645

642646

647+
#if PUBNUB_USE_SUBSCRIBE_V2
643648
pubnub_res pubnub_qt::subscribe_v2(QString const& channel, subscribe_v2_options opt)
644649
{
645650
QString prep_channels;
@@ -660,6 +665,7 @@ pubnub_res pubnub_qt::subscribe_v2(QString const& channel, subscribe_v2_options
660665
opt.get_timetoken(),
661666
PBTT_SUBSCRIBE_V2);
662667
}
668+
#endif // #if PUBNUB_USE_SUBSCRIBE_V2
663669

664670

665671
pubnub_res pubnub_qt::leave(QString const& channel, QString const& channel_group)

0 commit comments

Comments
 (0)