Skip to content

Commit

Permalink
Try to reconnect after 1 minute of no response
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpoz committed Jul 29, 2020
1 parent 78fedb7 commit 6ee6f47
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
17 changes: 15 additions & 2 deletions Client/Authentication/Network/AuthSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,19 @@ void HandleRealmLogonChallenge()

#endregion


// get next command
ReadCommand();
break;
}
case AuthResult.NO_MATCH:
Game.UI.LogLine("Unknown account name", LogLevel.Error);
failedAuthentications++;
if (failedAuthentications >= MAX_FAILED_AUTENTICATIONS)
{
Game.InvalidCredentials();
return;
}
break;
case AuthResult.ACCOUNT_IN_USE:
Game.UI.LogLine("Account already logged in", LogLevel.Error);
Expand All @@ -285,8 +294,11 @@ void HandleRealmLogonChallenge()
break;
}

// get next command
ReadCommand();
if (challenge.error != AuthResult.SUCCESS)
{
Game.Reconnect();
return;
}
}

void HandleRealmLogonProof()
Expand Down Expand Up @@ -445,6 +457,7 @@ public override bool Connect()
catch (SocketException ex)
{
Game.UI.LogLine(string.Format("Auth socket failed. ({0})", (SocketError)ex.ErrorCode), LogLevel.Error);
Game.Reconnect();
return false;
}

Expand Down
13 changes: 12 additions & 1 deletion Client/AutomatedGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ public void ConnectTo(WorldServerInfo server)
public virtual void Start()
{
// the initial socket is an AuthSocket - it will initiate its own asynch read
Running = socket.Connect();
Running = true;
socket.Connect();

Task.Run(async () =>
{
Expand All @@ -216,6 +217,16 @@ public override void Update()

(socket as WorldSocket)?.HandlePackets();

// Reconnect if it passed some time since last try of logging in
if (!Connected || !LoggedIn)
{
if (LastSentPacketTime < DateTime.Now.AddSeconds(-60) && LastSentPacketTime != default(DateTime))
{
Reconnect();
return;
}
}

if (World.SelectedCharacter == null)
return;

Expand Down

0 comments on commit 6ee6f47

Please sign in to comment.