Skip to content

docs: add 3.0.0 sample snippets and fix the client lookup in samples - #69

Merged
techwritermat merged 1 commit into
masterfrom
docs/samples-3.0-snippets
Nov 4, 2026
Merged

techwritermat merged 1 commit into
masterfrom
docs/samples-3.0-snippets

Conversation

@techwritermat

Copy link
Copy Markdown
Contributor

Summary

Adds the docs snippets that 3.0.0 is missing and fixes samples that still assumed the automatic client from the removed UPubnubSettings.

New snippets

Snippet marker File Content
set_user_id Sample_Configuration SetUserID, then checks FPubnubOperationResult::Error
get_user_id Sample_Configuration GetUserID
set_origin Sample_Configuration SetOrigin, then checks the result. An empty origin resets to the default
get_origin Sample_Configuration GetOrigin
disconnect_subscriptions Sample_Configuration DisconnectSubscriptions, then checks the result
reconnect_subscriptions Sample_Configuration ReconnectSubscriptions with the default timetoken, then checks the result
publish_with_compression Sample_PubSub PublishMethod = PPM_SendViaPOST and Compress = PPC_Yes, then PublishMessageAsync

Each marker is in both the header and the cpp, with snippet.hide/snippet.show around the client lookup, same as the existing samples. GetUserIDSample, GetOriginSample, and PublishWithCompressionSample are registered in RunSamples. The set, disconnect, and reconnect samples are not, because they change client state for the other samples.

Fixes

  • get_pubnub_client snippet: removed the "created automatically if PluginSettings are set" comment and the SetUserID call. It now explains that the first client you create has ID 0 and logs a warning when GetPubnubClient(0) returns nullptr.
  • Internal GetPubnubClient() helpers in 14 sample files called GetPubnubClient(0) and then dereferenced it. In 3.0.0 no client exists until you create one, so this was a null dereference. They now call a new protected APubnubSampleBase::GetOrCreateSampleClient() that returns client 0 or creates it with demo keys and UserID player_001. ASample_Configuration::RunSamples calls it first so its own get_pubnub_client snippet finds the client.
  • File header note in 15 sample files: replaced the ProjectSettings and InitializeAutomatically assumption with CreatePubnubClient and FPubnubConfig.
  • README: supported Unreal Engine versions are now 5.0-5.8 from source and 5.2-5.8 through Fab, matching .pubnub.yml.

How verified

No Unreal Engine is available, so nothing was compiled or run. Verified by review only:

  • API names and signatures checked against PubnubClient.h (SetUserID, GetUserID, SetOrigin, GetOrigin, ReconnectSubscriptions, DisconnectSubscriptions), PubnubStructLibrary.h (FPubnubPublishSettings::PublishMethod, Compress, FPubnubOperationResult::ErrorMessage), PubnubEnumLibrary.h (PPM_SendViaPOST, PPC_Yes) and PubnubSubsystem.cpp (client IDs start at 0, GetPubnubClient returns nullptr for unknown IDs).
  • Every snippet marker referenced by the Unreal docs (433 references) resolves against this branch.

🤖 Generated with Claude Code

Add snippets for SetUserID, GetUserID, SetOrigin, GetOrigin,
DisconnectSubscriptions, ReconnectSubscriptions, and publish with
compression. Fix the get_pubnub_client snippet and the sample client
helpers, which relied on the client that UPubnubSettings created
automatically before 3.0.0. Update the supported Unreal Engine versions
in the README to 5.0-5.8 from source and 5.2-5.8 through Fab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@KGronek-Pubnub KGronek-Pubnub left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@techwritermat
techwritermat merged commit f54673c into master Nov 4, 2026
3 checks passed
@techwritermat
techwritermat deleted the docs/samples-3.0-snippets branch November 4, 2026 08:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants