I’m trying to track some stuff on the server side whenever a client creates a party. I have registerd a hook with the nakama Go runtime via initializer.RegisterAfterRt
using the PartyCreate
id, however the Envelope_PartyCreate
proto only includes whether the party is open and the max size. Is there a way to get the ID of the party that was created as well as the current presences?
Another option I’ve considered is trying to use the PartyJoin
id instead, but:
a) I’m not sure whther a join hook will be called for the person who creates a new party
and
b) The Envelope_PartyJoin
proto only includes the party id, so I’m still not sure how I’d go about getting the presences.
I was also facing same issue and here is the solution to access party id in GO,
func AfterPartyCreate(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, out *rtapi.Envelope, in *rtapi.Envelope) error {
logger.Info("AfterPartyCreate Hook called")
envelope, ok := out.Message.(*rtapi.Envelope_Party)
if !ok {
logger.Error("error getting envelope as AfterPartyCreate envelope")
return runtime.NewError("error getting envelope as AfterPartyCreate envelope", 13)
}
logger.Info(envelope.Party.PartyId)
return nil
}
Thanks @surajTLabs. I didn’t think the out
paramter was fully populated during this callback. I should have checked that. I was attempting to use the in
parameter instead. This makes sense though.
My only other qualm, then, is that there doesn’t seem to be a way to get party data for a given party id via the nakama server api.