Skip to content

Commit

Permalink
Add function to clear one or more of the RPCs registered by gameplay …
Browse files Browse the repository at this point in the history
…systems in Hiro.
  • Loading branch information
novabyte committed May 14, 2024
1 parent c7bb3de commit 77e9ceb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr

:warning: This server code is versioned separately to the download of the [Hiro game framework](https://heroiclabs.com/hiro/). :warning:

## [Unreleased]
- Add "UnregisterRpc" to clear the implementation of one or more of the RPCs registered by gameplay systems in Hiro.

## [1.10.0] - 2024-04-12
### Added
- (Unity) Add function to write score to regional leaderboards.
Expand Down
20 changes: 20 additions & 0 deletions base.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,23 @@ func WithIncentivesSystem(configFile string, register bool) SystemConfig {
register: register,
}
}

// UnregisterRpc clears the implementation of one or more RPCs registered in Nakama by Hiro gameplay systems with a
// no-op version (http response 404). This is useful to remove individual RPCs which you do not want to be callable by
// game clients:
//
// hiro.UnregisterRpc(initializer, hiro.RpcId_RPC_ID_ECONOMY_GRANT, hiro.RpcId_RPC_ID_INVENTORY_GRANT)
//
// The behaviour of `initializer.RegisterRpc` in Nakama is last registration wins. It's recommended to use UnregisterRpc
// only after `hiro.Init` has been executed.
func UnregisterRpc(initializer runtime.Initializer, ids ...RpcId) error {
noopFn := func(context.Context, runtime.Logger, *sql.DB, runtime.NakamaModule, string) (string, error) {
return "", runtime.NewError("not found", 12) // GRPC - UNIMPLEMENTED
}
for _, id := range ids {
if err := initializer.RegisterRpc(id.String(), noopFn); err != nil {
return err
}
}
return nil
}

0 comments on commit 77e9ceb

Please sign in to comment.