Can I use multiple runtime modules like Typescript and go in the same project?

I need to handle player disconnect which only looks possible in go runtime but I was using typescript runtime. So, Can I use multiple runtime modules like Typescript and go in the same project?

Hello @Anup30giri,

Yes, you can register functions and match handlers in any of the supported languages. Please be aware that if functions are registered with the same id in multiple runtimes the following preference order takes place: Go > Lua > JS.

Best.

@sesposito sorry to semi-hijack the thread, but I’m trying to achieve the same as OP. What’s the recommended way to deploy multiple modules for different runtimes? I guess copying and pasting the (compiled) module in the data/modules folder as the dockerfiles in the docs do? or are there other methods? I haven’t found anything in the dev console to upload binaries so I guess it can only be done manually

@ezl87 have a look at our project template, it sets up both TS and Go code in the same project.

Does the below code address the handling of player disconnects, such as in cases of internet disconnection or when a player closes the game?

func eventSessionEnd(ctx context.Context, logger runtime.Logger, evt *api.Event) {
	logger.Debug("process event session end: %+v", evt)
}

// noinspection GoUnusedExportedFunction
func InitModule(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, initializer runtime.Initializer) error {
	if err := initializer.RegisterEventSessionEnd(eventSessionEnd); err != nil {
		return err
	}
	logger.Info("Go modules loaded.")
	return nil
}

Yes it should log a message when a player disconnects.

yes it works but it’s taking a lot of time

You should have a look at the socket configurations.

Thanks for the help