I’m struggling to end an authoritative match using the GO runtime.
Reading the docs it says:
Authoritative match handlers will only stop when any of the callbacks return a
nil
state. You can choose to do this at any point during the lifetime of the match, whether or not there are still players connected to it.
I’ve been having problems with the matchmaker returning devices to the previous matches, instead of starting a new one.
I currently run the MatchTerminate function at the end of the MatchLeave event if presences reaches 0.
But Debugging the match loop has shown the the loop continues even after MatchTerminate is called. I assume the way I am returning a “nil state” is the problem.
This is my MatchTerminate function:
func (m *Match) MatchTerminate(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, dispatcher runtime.MatchDispatcher, tick int64, state interface{}, graceSeconds int) interface{} {
if state.(*MatchState).Debug {
logger.Printf(“match terminate match_id %v tick %v”, ctx.Value(runtime.RUNTIME_CTX_MATCH_ID), tick)
logger.Printf(“match terminate match_id %v grace seconds %v”, ctx.Value(runtime.RUNTIME_CTX_MATCH_ID), graceSeconds)
}return nil
}
Thanks for any help in advance!