Skip to content

Commit

Permalink
Add 'recompute' param to Satori's update-properties
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviofernandes004 committed Aug 2, 2023
1 parent 4bf4c19 commit aed4b35
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gorilla/websocket v1.5.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0
github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380
github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c
github.com/jackc/pgconn v1.14.0
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa
github.com/jackc/pgtype v1.14.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@ github.com/heroiclabs/nakama-common v1.28.0 h1:oj6voT/3xOkOjeWzPVkrH0ATakZT6WNLL
github.com/heroiclabs/nakama-common v1.28.0/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs=
github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380 h1:cPpoIEukbm0RmM7jzLApRVYQeZp9G1Sg1RsvyxcJ0d4=
github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs=
github.com/heroiclabs/nakama-common v1.28.1-0.20230731165244-63a5a47100ee h1:rDI4A+kMhbE5xzMdWYiDHAavt6zOa7ZjmShNUE2WafI=
github.com/heroiclabs/nakama-common v1.28.1-0.20230731165244-63a5a47100ee/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs=
github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c h1:WYodhJ3/FcxNkYHTH4QT07IFM48VTcg5R88f99xeL3I=
github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c/go.mod h1:Os8XeXGvHAap/p6M/8fQ3gle4eEXDGRQmoRNcPQTjXs=
github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
8 changes: 8 additions & 0 deletions server/runtime_javascript_nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -8294,6 +8294,14 @@ func (n *runtimeJavascriptNakamaModule) satoriPropertiesUpdate(r *goja.Runtime)
properties.Custom = customPropsMap
}

if recompute, ok := props["recompute"]; ok {
recomputeBool, ok := recompute.(bool)
if !ok {
panic(r.NewTypeError("expects recompute to be a boolean"))
}
properties.Recompute = &recomputeBool
}

if err := n.satori.PropertiesUpdate(n.ctx, id, properties); err != nil {
panic(r.NewGoError(fmt.Errorf("failed to satori update properties: %s", err.Error())))
}
Expand Down
8 changes: 8 additions & 0 deletions server/runtime_lua_nakama.go
Original file line number Diff line number Diff line change
Expand Up @@ -9986,6 +9986,14 @@ func (n *RuntimeLuaNakamaModule) satoriPropertiesUpdate(l *lua.LState) int {
return
}
properties.Custom = customMap
case "recompute":
if v.Type() != lua.LTBool {
conversionError = true
l.ArgError(3, "expects recompute value to be a bool")
return
}
recompute := lua.LVAsBool(v)
properties.Recompute = &recompute
}
})

Expand Down
5 changes: 3 additions & 2 deletions vendor/github.com/heroiclabs/nakama-common/runtime/runtime.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/internal/genopena
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2/options
github.com/grpc-ecosystem/grpc-gateway/v2/runtime
github.com/grpc-ecosystem/grpc-gateway/v2/utilities
# github.com/heroiclabs/nakama-common v1.28.1-0.20230731105719-fb1172396380
# github.com/heroiclabs/nakama-common v1.28.1-0.20230801104954-f68ccb40522c
## explicit; go 1.19
github.com/heroiclabs/nakama-common/api
github.com/heroiclabs/nakama-common/rtapi
Expand Down

0 comments on commit aed4b35

Please sign in to comment.