mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 02:15:41 +00:00
Suppress exception from closed writer
If writer is closed, the world is probably already cached. So just update its state and avatar count
This commit is contained in:
parent
8430783718
commit
df9a774e55
@ -277,20 +277,34 @@ public sealed partial class VirtualParadiseClient
|
||||
private async void OnWorldListNativeEvent(nint sender)
|
||||
{
|
||||
VirtualParadiseWorld world;
|
||||
|
||||
string name;
|
||||
int avatarCount;
|
||||
WorldState state;
|
||||
|
||||
lock (Lock)
|
||||
{
|
||||
string name = vp_string(sender, StringAttribute.WorldName);
|
||||
int avatarCount = vp_int(sender, IntegerAttribute.WorldUsers);
|
||||
var state = (WorldState)vp_int(sender, IntegerAttribute.WorldState);
|
||||
name = vp_string(sender, StringAttribute.WorldName);
|
||||
avatarCount = vp_int(sender, IntegerAttribute.WorldUsers);
|
||||
state = (WorldState)vp_int(sender, IntegerAttribute.WorldState);
|
||||
|
||||
world = new VirtualParadiseWorld(this, name) {AvatarCount = avatarCount, State = state};
|
||||
_worlds[name] = world;
|
||||
}
|
||||
|
||||
if (_worldListChannel is not null)
|
||||
try
|
||||
{
|
||||
await _worldListChannel.Writer.WriteAsync(world).ConfigureAwait(false);
|
||||
if (_worldListChannel is not null)
|
||||
{
|
||||
await _worldListChannel.Writer.WriteAsync(world).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (_worlds.TryGetValue(name, out world!))
|
||||
{
|
||||
world.AvatarCount = avatarCount;
|
||||
world.State = state;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user