// callback check for udp end session, load result file, check session type against sessionTypes
// if session matches last session in sessionTypes then stop server and clear sessionTypes
callback check for udp end session, load result file, check session type against sessionTypes
if session matches last session in sessionTypes then stop server and clear sessionTypes
// callback check for udp end session load result file check session type against sessionTypes // if session matches last session in sessionTypes then stop server and clear sessionTypes
func LoopCallback(message udp.Message) {
	switch a := message.(type) {
	case udp.EndSession:
		if sessionTypes == nil {
			logrus.Infof("Session types == nil. ignoring end session callback")
			return
		}
		filename := filepath.Base(string(a))
		results, err := LoadResult(filename)
		if err != nil {
			logrus.Errorf("Could not read session results for %s, err: %s", filename, err)
			return
		}
		var endSession SessionType
		for _, session := range sessionTypes {
			if session == SessionTypeRace {
				endSession = SessionTypeRace
				break
			} else if session == SessionTypeQualifying {
				endSession = SessionTypeQualifying
			} else if session == SessionTypePractice && endSession != SessionTypeQualifying {
				endSession = SessionTypePractice
			} else if session == SessionTypeBooking && (endSession != SessionTypeQualifying && endSession != SessionTypePractice) {
				endSession = SessionTypeBooking
			}
		}
		logrus.Infof("results type: %s, endSession: %s", results.Type, string(endSession))
		if results.Type == string(endSession) {
			logrus.Infof("Event end detected, stopping looped session.")
			sessionTypes = nil
			err := AssettoProcess.Stop()
			if err != nil {
				logrus.Errorf("Could not stop server, err: %s", err)
				return
			}
		}
	}
}
func LoopCallback ( message udp . Message ) { switch a := message . ( type ) { case udp . EndSession : if sessionTypes == nil { logrus . Infof ( " " ) return } filename := filepath . Base ( string ( a ) ) results , err := LoadResult ( filename ) if err != nil { logrus . Errorf ( " " , filename , err ) return } var endSession SessionType for _ , session := range sessionTypes { if session == SessionTypeRace { endSession = SessionTypeRace break } else if session == SessionTypeQualifying { endSession = SessionTypeQualifying } else if session == SessionTypePractice && endSession != SessionTypeQualifying { endSession = SessionTypePractice } else if session == SessionTypeBooking && ( endSession != SessionTypeQualifying && endSession != SessionTypePractice ) { endSession = SessionTypeBooking } } logrus . Infof ( " " , results . Type , string ( endSession ) ) if results . Type == string ( endSession ) { logrus . Infof ( " " ) sessionTypes = nil err := AssettoProcess . Stop ( ) if err != nil { logrus . Errorf ( " " , err ) return } } } }
callback check for udp end session, load result file, check session type against sessionTypes
if session matches last session in sessionTypes then stop server and clear sessionTypes
callback check for udp end session load result file check session type against sessionTypes if session matches last session in sessionTypes then stop server and clear sessionTypes