Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscription Event Engine and Events Listener implementation #196

Merged
merged 19 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ PenaltyExcessCharacter: 4
PenaltyReturnTypeOnItsOwnLine: 100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you use format for single files?
I want to reformat the whole repository but there are some issues with compilation so I'm confused how does it work on your side.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I didn't receive a penalty there.
Also, it already was there and the only thing which I changed was the Standard: value: Cpp11c++11` (previous value wasn't recognized)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mhm.
Please do not format whole codebase within this PR.

I want to do it at some point, but it makes ~80k lines change :D

PointerAlignment: Left
ReflowComments: true
SortIncludes: false
SortIncludes: Never
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
Expand All @@ -101,7 +101,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
Standard: c++11
TabWidth: 4
UseTab: Never
...
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
runner:
- os: ubuntu-latest
group: Default
- os: macos-13
group: macos-gh
# - os: macos-13
# group: macos-gh
Xavrax marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout project
uses: actions/checkout@v3
Expand Down
59 changes: 52 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ num_option(ONLY_PUBSUB_API "Only pubsub API" OFF)
num_option(USE_PROXY "Use proxy" ON)
num_option(USE_GZIP_COMPRESSION "Use gzip compression" ON)
num_option(RECEIVE_GZIP_RESPONSE "Use gzip decompression" ON)
num_option(USE_RETRY_CONFIGURATION "Use requests retry" OFF)
num_option(USE_SUBSCRIBE_V2 "Use subscribe v2" ON)
num_option(USE_SUBSCRIBE_EVENT_ENGINE "Use Subscribe Event Engine" OFF)
num_option(USE_ADVANCED_HISTORY "Use advanced history" ON)
num_option(USE_OBJECTS_API "Use objects API" ON)
num_option(USE_AUTO_HEARTBEAT "Use auto heartbeat" ON)
Expand Down Expand Up @@ -97,13 +99,16 @@ set(FLAGS "\
-D PUBNUB_PROXY_API=${USE_PROXY} \
-D PUBNUB_USE_GZIP_COMPRESSION=${USE_GZIP_COMPRESSION} \
-D PUBNUB_RECEIVE_GZIP_RESPONSE=${RECEIVE_GZIP_RESPONSE} \
-D PUBNUB_USE_RETRY_CONFIGURATION=${USE_RETRY_CONFIGURATION} \
-D PUBNUB_USE_SUBSCRIBE_V2=${USE_SUBSCRIBE_V2} \
-D PUBNUB_USE_SUBSCRIBE_EVENT_ENGINE=${USE_SUBSCRIBE_EVENT_ENGINE} \
-D PUBNUB_USE_OBJECTS_API=${USE_OBJECTS_API} \
-D PUBNUB_USE_ACTIONS_API=${USE_ACTIONS_API} \
-D PUBNUB_USE_AUTO_HEARTBEAT=${USE_AUTO_HEARTBEAT} \
-D PUBNUB_USE_GRANT_TOKEN_API=${USE_GRANT_TOKEN_API} \
-D PUBNUB_USE_REVOKE_TOKEN_API=${USE_REVOKE_TOKEN_API} \
-D PUBNUB_USE_FETCH_HISTORY=${USE_FETCH_HISTORY} \
-D PUBNUB_CRYPTO_API=${USE_CRYPTO_API} \
-D PUBNUB_RAND_INIT_VECTOR=${USE_LEGACY_CRYPTO_RANDOM_IV} \
-D PUBNUB_MBEDTLS=${MBEDTLS}")

Expand Down Expand Up @@ -324,13 +329,43 @@ if(${RECEIVE_GZIP_RESPONSE})
${CMAKE_CURRENT_LIST_DIR}/core/pbgzip_decompress.c)
endif()

if(${USE_SUBSCRIBE_V2})
if (${USE_RETRY_CONFIGURATION})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_request_retry_timer.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_retry_configuration.c)
endif ()

if(${USE_SUBSCRIBE_V2})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_v2.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_v2.c)
endif()

if(${USE_SUBSCRIBE_EVENT_ENGINE})
message(STATUS "Using subscribe event engine API")
set(LIB_SOURCEFILES
${LIB_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/lib/pbarray.c
${CMAKE_CURRENT_LIST_DIR}/lib/pbhash_set.c
${CMAKE_CURRENT_LIST_DIR}/lib/pbref_counter.c
${CMAKE_CURRENT_LIST_DIR}/lib/pbstrdup.c)
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_memory_utils.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_event_engine.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_states.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_events.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_effects.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_engine_transitions.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_subscribe_event_listener.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_entities.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_event_engine.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_subscribe_event_listener.c)
endif()

if(${USE_ADVANCED_HISTORY})
set(FEATURE_SOURCEFILES
${FEATURE_SOURCEFILES}
Expand Down Expand Up @@ -440,12 +475,7 @@ if(${OPENSSL})
set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_connect_openssl.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_aes_cbc.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_legacy.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_crypto.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbaes256.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_openssl_blocking_io.c
${FEATURE_SOURCEFILES})

set(FEATURE_SOURCEFILES
Expand All @@ -454,6 +484,16 @@ if(${OPENSSL})

set(LDLIBS ${LDLIBS})

if(USE_CRYPTO_API)
set(FEATURE_SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_aes_cbc.c
${CMAKE_CURRENT_LIST_DIR}/core/pbcc_crypto_legacy.c
${CMAKE_CURRENT_LIST_DIR}/core/pubnub_crypto.c
${CMAKE_CURRENT_LIST_DIR}/openssl/pbaes256.c
${FEATURE_SOURCEFILES})
endif()

if(UNIX)
set(FEATURE_SOURCEFILES ${FEATURE_SOURCEFILES} ${CMAKE_CURRENT_LIST_DIR}/openssl/pbpal_add_system_certs_posix.c)
elseif(WIN32 OR WIN64 OR MSVC)
Expand Down Expand Up @@ -669,6 +709,11 @@ if(${EXAMPLES})
subscribe_publish_from_callback
publish_callback_subloop_sample
publish_queue_callback_subloop)
if(${USE_SUBSCRIBE_EVENT_ENGINE})
set(EXAMPLE_LIST
subscribe_event_engine_sample
${EXAMPLE_LIST})
endif()
if (WITH_CPP)
set(CPP_EXAMPLE_LIST
subscribe_publish_callback_sample # Only supports callback!
Expand Down
1 change: 0 additions & 1 deletion core/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ pubnub_subscribe_v2_unittest: $(PROJECT_SOURCEFILES) $(SUBSCRIBE_V2_SOURCEFILES)
$(CGREEN_RUNNER) ./pubnub_subscribe_v2_unit_test.so
#$(GCOVR) -r . --html --html-details -o coverage.html


clean:
find . -type d -iname "*.dSYM" -exec rm -rf {} \+
find . -type f -name "*.so" -o -name "*.gcda" -o -name "*.gcno" -o -name "*.html" | xargs -r rm -rf
Expand Down
1 change: 1 addition & 0 deletions core/pbauto_heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ static int copy_context_settings(pubnub_t* pb_clone, pubnub_t const* pb)
PUBNUB_ASSERT_OPT(pb_valid_ctx_ptr(pb));

pubnub_mutex_lock(pb_clone->monitor);
pb_clone->core.auth_token = pb->core.auth_token;
Xavrax marked this conversation as resolved.
Show resolved Hide resolved
pb_clone->core.auth = pb->core.auth;
strcpy(pb_clone->core.user_id, pb->core.user_id);
if (PUBNUB_ORIGIN_SETTABLE) {
Expand Down
2 changes: 1 addition & 1 deletion core/pbcc_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#ifndef PBCC_CRYPTO_H
#define PBCC_CRYPTO_H
#if PUBNUB_CRYPTO_API

/** @file pbcc_crypto.h

Expand Down Expand Up @@ -294,7 +295,6 @@ void pbcc_set_crypto_module(struct pbcc_context *ctx, struct pubnub_crypto_provi
*/
pubnub_crypto_provider_t *pbcc_get_crypto_module(struct pbcc_context *ctx);

#if PUBNUB_CRYPTO_API
/**
Decrypt the message received from PubNub with the crypto module.

Expand Down
Loading
Loading