From 9f16e6cc77d7b956a34003af022a5974e6b7931e Mon Sep 17 00:00:00 2001 From: Oliver Booth Date: Wed, 30 Nov 2022 18:56:33 +0000 Subject: [PATCH] Move EnumerateWorldsAsync to Worlds partial --- VpSharp/src/VirtualParadiseClient.Worlds.cs | 22 +++++++++++++++++++++ VpSharp/src/VirtualParadiseClient.cs | 20 ------------------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/VpSharp/src/VirtualParadiseClient.Worlds.cs b/VpSharp/src/VirtualParadiseClient.Worlds.cs index b290206..a2e6c35 100644 --- a/VpSharp/src/VirtualParadiseClient.Worlds.cs +++ b/VpSharp/src/VirtualParadiseClient.Worlds.cs @@ -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 _worldSettings = new(); + private readonly ConcurrentDictionary _worlds = new(); private Channel? _worldListChannel = Channel.CreateUnbounded(); private TaskCompletionSource _worldSettingsCompletionSource = new(); + /// + /// Gets an enumerable of the worlds returned by the universe server. + /// + /// An containing values. + /// + /// This method will yield results back as they are received from the world server. To access a consumed collection, + /// use . + /// + /// + public IAsyncEnumerable EnumerateWorldsAsync() + { + _worldListChannel = Channel.CreateUnbounded(); + lock (Lock) + { + _ = vp_world_list(NativeInstanceHandle, 0); + } + + return _worldListChannel.Reader.ReadAllAsync(); + } + /// /// Gets a world by its name. /// diff --git a/VpSharp/src/VirtualParadiseClient.cs b/VpSharp/src/VirtualParadiseClient.cs index 00f951f..bfe0edf 100644 --- a/VpSharp/src/VirtualParadiseClient.cs +++ b/VpSharp/src/VirtualParadiseClient.cs @@ -402,26 +402,6 @@ public sealed partial class VirtualParadiseClient : IDisposable return CurrentWorld!; } - /// - /// Gets an enumerable of the worlds returned by the universe server. - /// - /// An containing values. - /// - /// This method will yield results back as they are received from the world server. To access a consumed collection, - /// use . - /// - /// - public IAsyncEnumerable EnumerateWorldsAsync() - { - _worldListChannel = Channel.CreateUnbounded(); - lock (Lock) - { - vp_world_list(NativeInstanceHandle, 0); - } - - return _worldListChannel.Reader.ReadAllAsync(); - } - /// /// Leaves the current world. ///