Client LuaCsForBarotrauma
CompositeServerProvider.cs
1 #nullable enable
2 using System;
3 using System.Collections.Immutable;
6 
7 namespace Barotrauma
8 {
10  {
11  private readonly ImmutableArray<ServerProvider> providers;
12 
13  public CompositeServerProvider(params ServerProvider[] providers)
14  {
15  this.providers = providers.ToImmutableArray();
16  }
17 
18  protected override void RetrieveServersImpl(Action<ServerInfo, ServerProvider> onServerDataReceived, Action onQueryCompleted)
19  {
20  int providersFinished = 0;
21  void ackFinishedProvider()
22  {
23  providersFinished++;
24  if (providersFinished == providers.Length)
25  {
26  onQueryCompleted();
27  }
28  }
29  providers.ForEach(p => p.RetrieveServers(onServerDataReceived, ackFinishedProvider));
30  }
31 
32  public override void Cancel()
33  => providers.ForEach(p => p.Cancel());
34  }
35 }
CompositeServerProvider(params ServerProvider[] providers)
override void RetrieveServersImpl(Action< ServerInfo, ServerProvider > onServerDataReceived, Action onQueryCompleted)