Skip to content

Make UserPresence and Party fields publicly accessible#56

Open
Konstix08 wants to merge 6 commits into
heroiclabs:masterfrom
Konstix08:master
Open

Make UserPresence and Party fields publicly accessible#56
Konstix08 wants to merge 6 commits into
heroiclabs:masterfrom
Konstix08:master

Conversation

@Konstix08
Copy link
Copy Markdown

Summary

The UserPresence class and Party struct are declared public, but
their stored properties and initializers are internal (default access
level). This makes the party realtime API effectively unusable from
client code:

  • Party.id, leader, presences, self_p cannot be read from
    outside the module, so onPartyReceived callback payloads are opaque.
  • UserPresence.userId, sessionId, username cannot be read, so
    party member presences received from callbacks cannot be displayed.
  • UserPresence.init(from:) is internal, so the Nakama_Realtime_UserPresence
    proto type received in onPartyPresence cannot be converted to
    UserPresence for passing to removePartyMember(presence:) or
    promotePartyMember(partyMember:).

This PR adds the missing public modifiers. Mirrors the pattern already
applied in #51 for ApiAccount/ApiUser.

Changes

  • Sources/Nakama/Models/UserPresence.swift: public on stored
    properties and both initializers.
  • Sources/Nakama/Models/Party.swift: public on stored properties.

No behavioral or API-shape changes — only access level widening.

Copilot AI review requested due to automatic review settings May 16, 2026 12:06
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 16, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds missing public access modifiers to stored properties and initializers of UserPresence and Party so that consumers of the Nakama Swift SDK can actually read fields returned through the party realtime callbacks. Follows the same pattern previously applied to ApiAccount/ApiUser in #51.

Changes:

  • Expose UserPresence stored properties and both initializers as public.
  • Expose Party stored properties as public.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
Sources/Nakama/Models/UserPresence.swift Adds public to all stored properties and the designated/convenience initializers.
Sources/Nakama/Models/Party.swift Adds public to all stored properties of the Party struct.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Konstix08 and others added 4 commits May 17, 2026 02:11
Syncs proto/github.com/heroiclabs/nakama-common/{api,rtapi}.proto
with upstream heroiclabs/nakama-common master and regenerates the
SwiftProtobuf bindings via proto/generate.sh.

The stale rtapi/realtime.proto was missing the Party.hidden and
Party.label fields (added upstream long ago), which shifted Party's
self/leader/presences down by one field number. Servers running a
current Nakama build send field 5=self and field 6=leader, while
this SDK was decoding field 5 into `leader` and field 6 into
`presences`. Net effect: a joining client sees its own UserPresence
under `leader`, and the broadcast's real leader is the sole entry
in `presences`. PartyCreate.label and PartyCreate.hidden were
likewise missing.

api.proto has new entries from upstream as well; those are picked
up by the same regeneration pass.
Regenerate api.pb.swift and realtime.pb.swift from current proto
Mirrors addFriends/deleteFriends so apps can block users without
dropping to the raw gRPC layer.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Pending socket promises are stored in a [String: Any] keyed by collation
id. The error envelope handler tried to fail them via two as? casts —
to EventLoopPromise<Any> and EventLoopPromise<Google_Protobuf_Empty> —
neither of which matches a concrete EventLoopPromise<Nakama_Api_Rpc>
(or PartyMatchmakerTicket, Party, Channel, …). EventLoopPromise<T> is
invariant in T, so the cast silently fails and the awaiting caller
hangs forever on a server-side RPC error.

Add a parallel [String: (Error) -> Void] side-table populated in send()
with a closure that captures the typed promise and calls .fail on it.
The error branch uses that closure for any concrete T, then evicts
both entries so the dictionaries don't leak across requests.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.

3 participants