mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-22 19:18:47 +00:00
Move EnumerateWorldsAsync to Worlds partial
This commit is contained in:
parent
c2748567fc
commit
9f16e6cc77
@ -1,15 +1,37 @@
|
||||
using System.Collections.Concurrent;
|
||||
using System.Threading.Channels;
|
||||
using VpSharp.Entities;
|
||||
using static VpSharp.Internal.Native;
|
||||
|
||||
namespace VpSharp;
|
||||
|
||||
public sealed partial class VirtualParadiseClient
|
||||
{
|
||||
private readonly ConcurrentDictionary<string, string> _worldSettings = new();
|
||||
private readonly ConcurrentDictionary<string, VirtualParadiseWorld> _worlds = new();
|
||||
private Channel<VirtualParadiseWorld>? _worldListChannel = Channel.CreateUnbounded<VirtualParadiseWorld>();
|
||||
private TaskCompletionSource _worldSettingsCompletionSource = new();
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerable of the worlds returned by the universe server.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IAsyncEnumerable{T}" /> containing <see cref="VirtualParadiseWorld" /> values.</returns>
|
||||
/// <remarks>
|
||||
/// This method will yield results back as they are received from the world server. To access a consumed collection,
|
||||
/// use <see cref="GetWorldsAsync" />.
|
||||
/// </remarks>
|
||||
/// <seealso cref="GetWorldsAsync" />
|
||||
public IAsyncEnumerable<VirtualParadiseWorld> EnumerateWorldsAsync()
|
||||
{
|
||||
_worldListChannel = Channel.CreateUnbounded<VirtualParadiseWorld>();
|
||||
lock (Lock)
|
||||
{
|
||||
_ = vp_world_list(NativeInstanceHandle, 0);
|
||||
}
|
||||
|
||||
return _worldListChannel.Reader.ReadAllAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a world by its name.
|
||||
/// </summary>
|
||||
|
@ -402,26 +402,6 @@ public sealed partial class VirtualParadiseClient : IDisposable
|
||||
return CurrentWorld!;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerable of the worlds returned by the universe server.
|
||||
/// </summary>
|
||||
/// <returns>An <see cref="IAsyncEnumerable{T}" /> containing <see cref="VirtualParadiseWorld" /> values.</returns>
|
||||
/// <remarks>
|
||||
/// This method will yield results back as they are received from the world server. To access a consumed collection,
|
||||
/// use <see cref="GetWorldsAsync" />.
|
||||
/// </remarks>
|
||||
/// <seealso cref="GetWorldsAsync" />
|
||||
public IAsyncEnumerable<VirtualParadiseWorld> EnumerateWorldsAsync()
|
||||
{
|
||||
_worldListChannel = Channel.CreateUnbounded<VirtualParadiseWorld>();
|
||||
lock (Lock)
|
||||
{
|
||||
vp_world_list(NativeInstanceHandle, 0);
|
||||
}
|
||||
|
||||
return _worldListChannel.Reader.ReadAllAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Leaves the current world.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user