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:
Oliver Booth 2022-12-04 15:28:49 +00:00
parent 8430783718
commit df9a774e55
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
1 changed files with 20 additions and 6 deletions

View File

@ -277,22 +277,36 @@ 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;
}
try
{
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;
}
}
}
private void OnWorldSettingNativeEvent(nint sender)
{