Using the template project: GitHub - heroiclabs/nakama-project-template: An example project on how to set up and write custom server code in Nakama server., I tried to use logger to log something in MatchInit
- but it doesn’t seem to work:
func (m *MatchHandler) MatchInit(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, params map[string]interface{}) (interface{}, int, string) {
logger.Info("hello world!!!")
fast, ok := params["fast"].(bool)
if !ok {
...
I have a client using JS SDK to then call createMatch()
and I know the call went through because I see this in Nakama log:
backend | {"level":"debug","ts":"2023-03-24T13:15:04.161Z","caller":"server/pipeline.go:65","msg":"Received *rtapi.Envelope_MatchCreate message","uid":"f4256a05-405c-46fd-bee9-8010
7543087f","sid":"e3c7a5e8-ca45-11ed-892e-006100a0eb06","cid":"2","message":{"MatchCreate":{}}}
backend | {"level":"debug","ts":"2023-03-24T13:15:04.162Z","caller":"server/tracker.go:907","msg":"Processing presence event","joins":1,"leaves":0}
backend | {"level":"debug","ts":"2023-03-24T13:15:04.162Z","caller":"server/session_ws.go:395","msg":"Sending *rtapi.Envelope_Match message","uid":"f4256a05-405c-46fd-bee9-80107543
087f","sid":"e3c7a5e8-ca45-11ed-892e-006100a0eb06","envelope":"cid:\"2\" match:{match_id:\"eb9d0410-8fa0-4758-abf9-16b589f69eda.\" size:1 self:{user_id:\"f4256a05-405c-46fd-bee9-80107543087f
\" session_id:\"e3c7a5e8-ca45-11ed-892e-006100a0eb06\" username:\"Kbgstmxgtw\"}}"}
backend | {"level":"debug","ts":"2023-03-24T13:15:04.165Z","caller":"server/pipeline.go:65","msg":"Received *rtapi.Envelope_MatchJoin message","uid":"c77188ae-a9d2-4159-b46d-c17999
7ee867","sid":"e3c8a9b6-ca45-11ed-892e-006100a0eb06","cid":"2","message":{"MatchJoin":{"Id":{"MatchId":"eb9d0410-8fa0-4758-abf9-16b589f69eda."}}}}
backend | {"level":"debug","ts":"2023-03-24T13:15:04.165Z","caller":"server/tracker.go:907","msg":"Processing presence event","joins":1,"leaves":0}
backend | {"level":"debug","ts":"2023-03-24T13:15:04.166Z","caller":"server/session_ws.go:395","msg":"Sending *rtapi.Envelope_Match message","uid":"c77188ae-a9d2-4159-b46d-c179997e
e867","sid":"e3c8a9b6-ca45-11ed-892e-006100a0eb06","envelope":"cid:\"2\" match:{match_id:\"eb9d0410-8fa0-4758-abf9-16b589f69eda.\" size:1 presences:{user_id:\"f4256a05-405c-46fd-bee9-8010754
3087f\" session_id:\"e3c7a5e8-ca45-11ed-892e-006100a0eb06\" username:\"Kbgstmxgtw\"} self:{user_id:\"c77188ae-a9d2-4159-b46d-c179997ee867\" session_id:\"e3c8a9b6-ca45-11ed-892e-006100a0eb06\
" username:\"nAFsZBsiXQ\"}}"}
But no where in the log could I see my hello world!!!
. I also tried to add this to the typescript module from that example project:
let matchInit: nkruntime.MatchInitFunction<State> = function (ctx: nkruntime.Context, logger: nkruntime.Logger, nk: nkruntime.Nakama, params: {[key: string]: string}) {
logger.info("hello world!!!")
const fast = !!params['fast'];
...
When testing typescript I removed the go build process from the dockerfile (to avoid conflicts). Same problem as with Go. Lastly, my match is not Authoritative according to the console, how do I make it so that it is?:
I am using the sample project with no other changes, I did this because I couldn’t get it working in my own project either. I’m sure I’m missing something obvious but I can’t seem to figure it out. Any help would be appreciated, thank you.
- Versions: Docker
heroiclabs/nakama:3.9.0
, Dockerheroiclabs/nakama:3.15.0
(tried both) - Server Framework Runtime language: Go, TS