QR2: Kick player on message ack timeout

This commit is contained in:
mkwcat 2024-01-23 17:20:33 -05:00
parent 7963d26a6a
commit 07d8f3d079
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9
3 changed files with 22 additions and 5 deletions

View File

@ -22,6 +22,11 @@ func kickPlayer(profileID uint32, reason string) {
case "invalid_elo":
errorMessage = WWFCMsgInvalidELO
case "network_error":
// No error message
session.Conn.Close()
return
}
session.replyError(GPError{

View File

@ -154,6 +154,7 @@ func (g *GameSpySession) login(command common.GameSpyCommand) {
deviceId := uint32(0)
g.GameName = command.OtherValues["gamename"]
logging.Info(g.ModuleName, "Game name:", aurora.Cyan(g.GameName))
g.GameCode = gamecd
g.Region = region
g.Language = lang

View File

@ -235,6 +235,10 @@ func SendClientMessage(senderIP string, destSearchID uint64, message []byte) {
payload = append(payload, message...)
receiver.MessageMutex.Lock()
if receiver.Login == nil {
receiver.MessageMutex.Unlock()
return
}
s := sleep.Sleeper{}
s.AddWaker(&receiver.MessageAckWaker)
@ -257,12 +261,19 @@ func SendClientMessage(senderIP string, destSearchID uint64, message []byte) {
switch s.Fetch(true) {
case &timeWaker:
timeOutCount++
if timeOutCount > 8 {
logging.Error(moduleName, "Timed out waiting for ack")
receiver.MessageMutex.Unlock()
return
if timeOutCount <= 8 {
break
}
break
logging.Error(moduleName, "Timed out waiting for ack")
// Kick the player
if login := receiver.Login; login != nil {
login.GPErrorCallback(login.ProfileID, "network_error")
receiver.Login = nil
}
receiver.MessageMutex.Unlock()
return
default:
receiver.MessageMutex.Unlock()