mirror of
https://github.com/Facepunch/Facepunch.Steamworks.git
synced 2025-02-03 01:00:34 +03:00
Merge from temp_browser_fix -> master
- make IPList disposable - list Unresponsive vs Unqueried servers seperately)
This commit is contained in:
commit
62a1ae78e5
@ -69,6 +69,27 @@ namespace Steamworks
|
||||
}
|
||||
}
|
||||
|
||||
// Used to reproduce steam serverlist stopping querying after ~10s around august 2023
|
||||
[TestMethod]
|
||||
public async Task RustServerListTest()
|
||||
{
|
||||
using ( var list = new ServerList.Internet() )
|
||||
{
|
||||
list.AddFilter( "secure", "1" );
|
||||
list.AddFilter( "and", "1" );
|
||||
list.AddFilter( "gametype", "v2405" );
|
||||
list.AddFilter( "appid", "252490" );
|
||||
list.AddFilter( "gamedir", "rust" );
|
||||
list.AddFilter( "empty", "1" );
|
||||
|
||||
var success = await list.RunQueryAsync( 90 );
|
||||
|
||||
Console.WriteLine( $"success {success}" );
|
||||
Console.WriteLine( $"Found {list.Responsive.Count} Responsive Servers" );
|
||||
Console.WriteLine( $"Found {list.Unresponsive.Count} Unresponsive Servers" );
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task SourceQuery()
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ namespace Steamworks.ServerList
|
||||
/// </summary>
|
||||
public List<ServerInfo> Unresponsive = new List<ServerInfo>();
|
||||
|
||||
public List<ServerInfo> Unqueried = new List<ServerInfo>();
|
||||
|
||||
public Base()
|
||||
{
|
||||
@ -134,7 +135,7 @@ namespace Steamworks.ServerList
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
public virtual void Dispose()
|
||||
{
|
||||
ReleaseQuery();
|
||||
}
|
||||
@ -176,8 +177,10 @@ namespace Steamworks.ServerList
|
||||
{
|
||||
watchList.RemoveAll( x =>
|
||||
{
|
||||
var info = Internal.GetServerDetails( request, x );
|
||||
OnServer( ServerInfo.From( info ), info.HadSuccessfulResponse );
|
||||
var details = Internal.GetServerDetails( request, x );
|
||||
var info = ServerInfo.From( details );
|
||||
info.Ping = int.MaxValue;
|
||||
Unqueried.Add( info );
|
||||
return true;
|
||||
} );
|
||||
}
|
||||
@ -194,4 +197,4 @@ namespace Steamworks.ServerList
|
||||
Unresponsive.Add( serverInfo );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
using Steamworks.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Steamworks.ServerList
|
||||
@ -30,15 +26,17 @@ namespace Steamworks.ServerList
|
||||
|
||||
var ips = Ips.ToArray();
|
||||
|
||||
while ( true )
|
||||
wantsCancel = false;
|
||||
|
||||
while ( !wantsCancel )
|
||||
{
|
||||
var sublist = ips.Skip( pointer ).Take( blockSize );
|
||||
if ( sublist.Count() == 0 )
|
||||
var sublist = ips.Skip( pointer ).Take( blockSize ).ToList();
|
||||
if ( sublist.Count == 0 )
|
||||
break;
|
||||
|
||||
using ( var list = new ServerList.Internet() )
|
||||
{
|
||||
list.AddFilter( "or", sublist.Count().ToString() );
|
||||
list.AddFilter( "or", sublist.Count.ToString() );
|
||||
|
||||
foreach ( var server in sublist )
|
||||
{
|
||||
@ -47,9 +45,6 @@ namespace Steamworks.ServerList
|
||||
|
||||
await list.RunQueryAsync( timeoutSeconds );
|
||||
|
||||
if ( wantsCancel )
|
||||
return false;
|
||||
|
||||
Responsive.AddRange( list.Responsive );
|
||||
Responsive = Responsive.Distinct().ToList();
|
||||
Unresponsive.AddRange( list.Unresponsive );
|
||||
@ -64,9 +59,17 @@ namespace Steamworks.ServerList
|
||||
return true;
|
||||
}
|
||||
|
||||
// note: Cancel doesn't get called in Dispose because request is always null for this class
|
||||
public override void Cancel()
|
||||
{
|
||||
wantsCancel = true;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
base.Dispose();
|
||||
|
||||
wantsCancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user