mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-08-03 16:59:34 -05:00
QR2: Kick player on message ack timeout
This commit is contained in:
parent
7963d26a6a
commit
07d8f3d079
|
|
@ -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{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user