Try to fix failing connects.

This commit is contained in:
Ray Koopa 2019-01-22 18:32:31 +01:00
parent 1b527a3f20
commit e9c88caadc

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua;
using Syroot.Worms.Mgame.GameServer.Packets.WorldPartyAqua.Server;
@ -6,6 +7,10 @@ namespace Syroot.Worms.Mgame.GameServer
{
internal partial class Client
{
// ---- FIELDS -------------------------------------------------------------------------------------------------
private int _sendConnectTries;
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
public void HandleWwpaServerChannelList(ChannelListQuery packet)
@ -81,16 +86,23 @@ namespace Syroot.Worms.Mgame.GameServer
});
}
public void HandleWwpaServerConnect(ConnectQuery packet)
public async void HandleWwpaServerConnect(ConnectQuery packet)
{
// Client fails to detect reply at rare times due to unknown reasons.
SendPacket(new ConnectReply { ServerVersion = _server.Config.Version });
// Client fails to detect reply at rare times due to unknown reasons. Resend packet some times.
ConnectReply reply = new ConnectReply { ServerVersion = _server.Config.Version };
_sendConnectTries = 10;
while (_sendConnectTries-- > 0)
{
SendPacket(reply);
await Task.Delay(500);
}
}
public void HandleWwpaServerDisconnect(DisconnectNotice packet) { }
public void HandleWwpaServerLogin(LoginQuery packet)
{
_sendConnectTries = 0;
SendPacket(new LoginReply { Result = LoginResult.Success });
}