3 using System.Collections.Generic;
4 using System.Collections.Immutable;
6 using System.Threading.Tasks;
23 public override void Write(XElement element) { }
26 protected override void RetrieveServersImpl(Action<ServerInfo, ServerProvider> onServerDataReceived, Action onQueryCompleted)
28 if (EosInterface.IdQueries.GetLoggedInPuids() is not { Length: > 0 } loggedInPuids) {
return; }
30 int finishedTaskCount = 0;
31 int totalTaskCount = EosInterface.Sessions.MaxBucketIndex + 1 - EosInterface.Sessions.MinBucketIndex;
33 void countTaskFinished()
36 if (finishedTaskCount == totalTaskCount)
42 void onTaskFinished(Task t)
44 using var janitor = Janitor.Start();
45 janitor.AddAction(countTaskFinished);
48 out Result<ImmutableArray<EosInterface.Sessions.RemoteSession>, EosInterface.Sessions.RemoteSession.Query.Error>? result))
53 if (!result.TryUnwrapSuccess(out var sessions))
58 var addedEndpoints =
new HashSet<Endpoint>();
59 foreach (var session
in sessions)
61 if (!session.Attributes.TryGetValue(
"ServerName".ToIdentifier(), out var serverName))
67 if (!endpointOption.TryUnwrap(out var primaryEndpoint))
72 var endpoints =
new List<Endpoint> { primaryEndpoint };
74 && session.Attributes.TryGetValue(
"SteamP2PEndpoint".ToIdentifier(), out var steamIdStr)
77 endpoints.Add(steamP2PEndpoint);
81 Address: LidgrenAddress address, Port: NetConfig.DefaultPort
83 && session.Attributes.TryGetValue(
"Port".ToIdentifier(), out var portStr)
84 && ushort.TryParse(portStr, out var port))
91 endpoints[0] = primaryEndpoint;
95 if (endpoints.Intersect(addedEndpoints).Any())
100 addedEndpoints.UnionWith(endpoints);
102 var serverInfo =
new ServerInfo(endpoints.ToImmutableArray())
104 ServerName = serverName
107 session.Attributes.TryGetValue(key.ToIdentifier(), out var value) ? value :
string.Empty);
108 serverInfo.EosCrossplay =
true;
109 serverInfo.Checked =
true;
111 if (session.Attributes.TryGetValue(
"steampinglocation".ToIdentifier(), out var steamPingLocation))
116 onServerDataReceived(serverInfo,
this);
120 for (
int bucketIndex = EosInterface.Sessions.MinBucketIndex; bucketIndex <= EosInterface.Sessions.MaxBucketIndex; bucketIndex++)
122 var query =
new EosInterface.Sessions.RemoteSession.Query(
123 BucketIndex: bucketIndex,
124 LocalUserId: loggedInPuids.First(),
126 Attributes: ImmutableDictionary<Identifier, string>.Empty);
129 $
"{nameof(EosServerProvider)}.{nameof(RetrieveServersImpl)}",
static Option< Endpoint > Parse(string str)
void UpdateInfo(Func< string, string?> valueGetter)
static new Option< SteamP2PEndpoint > Parse(string endpointStr)
DataSource(string steamPingLocation)
override void Write(XElement element)
readonly string SteamPingLocation
override void RetrieveServersImpl(Action< ServerInfo, ServerProvider > onServerDataReceived, Action onQueryCompleted)