mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 20:42:55 +08:00
Merge pull request #11359 from peppy/fix-error-spam-on-disconnection
This commit is contained in:
commit
575a00dd7d
@ -52,6 +52,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1228.0" />
|
<PackageReference Include="ppy.osu.Framework.Android" Version="2020.1229.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
@ -293,8 +294,21 @@ namespace osu.Game.Online.API
|
|||||||
failureCount = 0;
|
failureCount = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
catch (HttpRequestException re)
|
||||||
|
{
|
||||||
|
log.Add($"{nameof(HttpRequestException)} while performing request {req}: {re.Message}");
|
||||||
|
handleFailure();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (SocketException se)
|
||||||
|
{
|
||||||
|
log.Add($"{nameof(SocketException)} while performing request {req}: {se.Message}");
|
||||||
|
handleFailure();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
catch (WebException we)
|
catch (WebException we)
|
||||||
{
|
{
|
||||||
|
log.Add($"{nameof(WebException)} while performing request {req}: {we.Message}");
|
||||||
handleWebException(we);
|
handleWebException(we);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -312,7 +326,7 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IBindable<APIState> State => state;
|
public IBindable<APIState> State => state;
|
||||||
|
|
||||||
private bool handleWebException(WebException we)
|
private void handleWebException(WebException we)
|
||||||
{
|
{
|
||||||
HttpStatusCode statusCode = (we.Response as HttpWebResponse)?.StatusCode
|
HttpStatusCode statusCode = (we.Response as HttpWebResponse)?.StatusCode
|
||||||
?? (we.Status == WebExceptionStatus.UnknownError ? HttpStatusCode.NotAcceptable : HttpStatusCode.RequestTimeout);
|
?? (we.Status == WebExceptionStatus.UnknownError ? HttpStatusCode.NotAcceptable : HttpStatusCode.RequestTimeout);
|
||||||
@ -330,26 +344,24 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
case HttpStatusCode.Unauthorized:
|
case HttpStatusCode.Unauthorized:
|
||||||
Logout();
|
Logout();
|
||||||
return true;
|
break;
|
||||||
|
|
||||||
case HttpStatusCode.RequestTimeout:
|
case HttpStatusCode.RequestTimeout:
|
||||||
|
handleFailure();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleFailure()
|
||||||
|
{
|
||||||
failureCount++;
|
failureCount++;
|
||||||
log.Add($@"API failure count is now {failureCount}");
|
log.Add($@"API failure count is now {failureCount}");
|
||||||
|
|
||||||
if (failureCount < 3)
|
if (failureCount >= 3 && State.Value == APIState.Online)
|
||||||
// we might try again at an api level.
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (State.Value == APIState.Online)
|
|
||||||
{
|
{
|
||||||
state.Value = APIState.Failing;
|
state.Value = APIState.Failing;
|
||||||
flushQueue();
|
flushQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsLoggedIn => localUser.Value.Id > 1;
|
public bool IsLoggedIn => localUser.Value.Id > 1;
|
||||||
|
@ -84,7 +84,7 @@ namespace osu.Game.Online.Multiplayer
|
|||||||
IsConnected.BindValueChanged(connected =>
|
IsConnected.BindValueChanged(connected =>
|
||||||
{
|
{
|
||||||
// clean up local room state on server disconnect.
|
// clean up local room state on server disconnect.
|
||||||
if (!connected.NewValue)
|
if (!connected.NewValue && Room != null)
|
||||||
{
|
{
|
||||||
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
|
Logger.Log("Connection to multiplayer server was lost.", LoggingTarget.Runtime, LogLevel.Important);
|
||||||
LeaveRoom().CatchUnobservedExceptions();
|
LeaveRoom().CatchUnobservedExceptions();
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.1228.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.1229.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
<PackageReference Include="Sentry" Version="2.1.8" />
|
<PackageReference Include="Sentry" Version="2.1.8" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
<Reference Include="System.Net.Http" />
|
<Reference Include="System.Net.Http" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup Label="Package References">
|
<ItemGroup Label="Package References">
|
||||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1228.0" />
|
<PackageReference Include="ppy.osu.Framework.iOS" Version="2020.1229.0" />
|
||||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
<PackageReference Include="ppy.osu.Game.Resources" Version="2020.1202.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
<!-- See https://github.com/dotnet/runtime/issues/35988 (can be removed after Xamarin uses net5.0 / net6.0) -->
|
||||||
@ -88,7 +88,7 @@
|
|||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.6" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||||
<PackageReference Include="ppy.osu.Framework" Version="2020.1228.0" />
|
<PackageReference Include="ppy.osu.Framework" Version="2020.1229.0" />
|
||||||
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
<PackageReference Include="SharpCompress" Version="0.26.0" />
|
||||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||||
|
Loading…
Reference in New Issue
Block a user