When a client disconnects from the server (for example when the client app is closed), there are some db and storage actions that I need to do for that specific client. In order to do that, I need the nakama server to pass down an instance of *sql.DB and runtime.NakamaModule to the function that I have registered to RegisterEventSessionEnd.
If that is not possible, then can I cache the *sql.DB and runtime.NakamaModule that was passed to the latest rpc call and use them for my purpose?
Here is how I am currently testing the RegisterEventSessionEnd, but I cannot find an instance of *sql.DB and runtime.NakamaModule, neither in ctx, nor in evt
- Versions: Nakama {“version”:“3.12.0+f5e935d6”}, {Docker}
- Server Framework Runtime language (If relevant) {Go}
if err := initializer.RegisterEventSessionEnd(func(ctx context.Context, logger runtime.Logger, evt *api.Event) {
fmt.Println("============================= RegisterEventSessionEnd ==================================")
userId := ctx.Value(runtime.RUNTIME_CTX_USER_ID).(string)
sessionId := ctx.Value(runtime.RUNTIME_CTX_SESSION_ID).(string)
fmt.Printf("connection closed for userId '%s' and sessionId '%s'\n", userId, sessionId)
fmt.Println("***************************** RegisterEventSessionEnd **********************************")
}); err != nil {
return err
}