Make UserPresence and Party fields publicly accessible#56
Open
Konstix08 wants to merge 6 commits into
Open
Conversation
There was a problem hiding this comment.
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
UserPresencestored properties and both initializers aspublic. - Expose
Partystored properties aspublic.
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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
UserPresenceclass andPartystruct are declaredpublic, buttheir stored properties and initializers are
internal(default accesslevel). This makes the party realtime API effectively unusable from
client code:
Party.id,leader,presences,self_pcannot be read fromoutside the module, so
onPartyReceivedcallback payloads are opaque.UserPresence.userId,sessionId,usernamecannot be read, soparty member presences received from callbacks cannot be displayed.
UserPresence.init(from:)is internal, so theNakama_Realtime_UserPresenceproto type received in
onPartyPresencecannot be converted toUserPresencefor passing toremovePartyMember(presence:)orpromotePartyMember(partyMember:).This PR adds the missing
publicmodifiers. Mirrors the pattern alreadyapplied in #51 for
ApiAccount/ApiUser.Changes
Sources/Nakama/Models/UserPresence.swift:publicon storedproperties and both initializers.
Sources/Nakama/Models/Party.swift:publicon stored properties.No behavioral or API-shape changes — only access level widening.