mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 06:35: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,22 +277,36 @@ public sealed partial class VirtualParadiseClient
|
|||||||
private async void OnWorldListNativeEvent(nint sender)
|
private async void OnWorldListNativeEvent(nint sender)
|
||||||
{
|
{
|
||||||
VirtualParadiseWorld world;
|
VirtualParadiseWorld world;
|
||||||
|
string name;
|
||||||
|
int avatarCount;
|
||||||
|
WorldState state;
|
||||||
|
|
||||||
lock (Lock)
|
lock (Lock)
|
||||||
{
|
{
|
||||||
string name = vp_string(sender, StringAttribute.WorldName);
|
name = vp_string(sender, StringAttribute.WorldName);
|
||||||
int avatarCount = vp_int(sender, IntegerAttribute.WorldUsers);
|
avatarCount = vp_int(sender, IntegerAttribute.WorldUsers);
|
||||||
var state = (WorldState)vp_int(sender, IntegerAttribute.WorldState);
|
state = (WorldState)vp_int(sender, IntegerAttribute.WorldState);
|
||||||
|
|
||||||
world = new VirtualParadiseWorld(this, name) {AvatarCount = avatarCount, State = state};
|
world = new VirtualParadiseWorld(this, name) {AvatarCount = avatarCount, State = state};
|
||||||
_worlds[name] = world;
|
_worlds[name] = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (_worldListChannel is not null)
|
if (_worldListChannel is not null)
|
||||||
{
|
{
|
||||||
await _worldListChannel.Writer.WriteAsync(world).ConfigureAwait(false);
|
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)
|
private void OnWorldSettingNativeEvent(nint sender)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user