fix gpose and disposal of charas when losing sight
This commit is contained in:
@@ -206,7 +206,7 @@ public class CachedPlayer : MediatorSubscriberBase, IDisposable
|
|||||||
{
|
{
|
||||||
if (PlayerName == null || _currentOtherChara == null
|
if (PlayerName == null || _currentOtherChara == null
|
||||||
|| !string.Equals(PlayerName, _currentOtherChara.Name, StringComparison.Ordinal)
|
|| !string.Equals(PlayerName, _currentOtherChara.Name, StringComparison.Ordinal)
|
||||||
|| _currentOtherChara.Address == IntPtr.Zero)
|
|| _currentOtherChara.CurrentAddress == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class PairManager : MediatorSubscriberBase, IDisposable
|
|||||||
if (recreate)
|
if (recreate)
|
||||||
item.Value.RecreateCachedPlayer();
|
item.Value.RecreateCachedPlayer();
|
||||||
else
|
else
|
||||||
item.Value.Dispose();
|
item.Value.MarkOffline();
|
||||||
}
|
}
|
||||||
RecreateLazy();
|
RecreateLazy();
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ public class PairManager : MediatorSubscriberBase, IDisposable
|
|||||||
|
|
||||||
if (!pair.HasAnyConnection())
|
if (!pair.HasAnyConnection())
|
||||||
{
|
{
|
||||||
pair.Dispose();
|
pair.MarkOffline();
|
||||||
_allClientPairs.TryRemove(dto.User, out _);
|
_allClientPairs.TryRemove(dto.User, out _);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ public class PairManager : MediatorSubscriberBase, IDisposable
|
|||||||
pair.UserPair = null;
|
pair.UserPair = null;
|
||||||
if (!pair.HasAnyConnection())
|
if (!pair.HasAnyConnection())
|
||||||
{
|
{
|
||||||
pair.Dispose();
|
pair.MarkOffline();
|
||||||
_allClientPairs.TryRemove(dto.User, out _);
|
_allClientPairs.TryRemove(dto.User, out _);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -275,7 +275,7 @@ public class PairManager : MediatorSubscriberBase, IDisposable
|
|||||||
{
|
{
|
||||||
if (!pair.CachedPlayerExists)
|
if (!pair.CachedPlayerExists)
|
||||||
{
|
{
|
||||||
pair.Dispose();
|
pair.RecreateCachedPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class MareMediator : IDisposable
|
|||||||
lock (_addRemoveLock)
|
lock (_addRemoveLock)
|
||||||
{
|
{
|
||||||
var removed = _subscriberDict[message.GetType()].RemoveWhere(s => s == subscriber);
|
var removed = _subscriberDict[message.GetType()].RemoveWhere(s => s == subscriber);
|
||||||
_logger.LogCritical(ex, "Error executing {type} for subscriber {subscriber}, removed from Mediator: {removeCount}", message.GetType(), subscriber, removed);
|
_logger.LogCritical(ex, "Error executing {type} for subscriber {subscriber}, removed from Mediator: {removeCount}", message.GetType().Name, subscriber.Subscriber.GetType().Name, removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace MareSynchronos.Models;
|
namespace MareSynchronos.Models;
|
||||||
|
|
||||||
public class Pair : IDisposable
|
public class Pair
|
||||||
{
|
{
|
||||||
private readonly ILogger<Pair> _logger;
|
private readonly ILogger<Pair> _logger;
|
||||||
private readonly CachedPlayerFactory _cachedPlayerFactory;
|
private readonly CachedPlayerFactory _cachedPlayerFactory;
|
||||||
@@ -140,7 +140,7 @@ public class Pair : IDisposable
|
|||||||
|
|
||||||
public void RecreateCachedPlayer(OnlineUserIdentDto? dto = null, ApiController? controller = null)
|
public void RecreateCachedPlayer(OnlineUserIdentDto? dto = null, ApiController? controller = null)
|
||||||
{
|
{
|
||||||
if (dto == null && _onlineUserIdentDto == null || _apiController == null && controller == null) return;
|
if ((dto == null && _onlineUserIdentDto == null) || (_apiController == null && controller == null)) return;
|
||||||
if (dto != null || controller != null)
|
if (dto != null || controller != null)
|
||||||
{
|
{
|
||||||
_onlineUserIdentDto = dto;
|
_onlineUserIdentDto = dto;
|
||||||
@@ -158,12 +158,4 @@ public class Pair : IDisposable
|
|||||||
CachedPlayer?.Dispose();
|
CachedPlayer?.Dispose();
|
||||||
CachedPlayer = null;
|
CachedPlayer = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
_onlineUserIdentDto = null;
|
|
||||||
LastReceivedCharacterData = null;
|
|
||||||
CachedPlayer?.Dispose();
|
|
||||||
CachedPlayer = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -360,7 +360,6 @@ public partial class ApiController : MediatorSubscriberBase, IDisposable, IMareH
|
|||||||
CurrentUploads.Clear();
|
CurrentUploads.Clear();
|
||||||
CurrentDownloads.Clear();
|
CurrentDownloads.Clear();
|
||||||
Mediator.Publish(new DisconnectedMessage());
|
Mediator.Publish(new DisconnectedMessage());
|
||||||
_pairManager.ClearPairs();
|
|
||||||
_mareHub = null;
|
_mareHub = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user