mirror of
https://github.com/RaindropViewer/RaindropViewer.git
synced 2026-07-27 22:11:39 +00:00
refactor: add IDisposable to AgentTracker
This commit is contained in:
committed by
alexiscatnip
parent
a1ae85d21e
commit
eb5f2be103
@@ -9,7 +9,7 @@ namespace Raindrop
|
||||
// in particular, it tracks :
|
||||
// region handle
|
||||
//
|
||||
public class AgentsTracker
|
||||
public class AgentsTracker : IDisposable
|
||||
{
|
||||
//hashtable of agents, and the sim they are last known to reside in.
|
||||
public readonly Dictionary<UUID, NearbyAvatar> agentInfos = new Dictionary<UUID, NearbyAvatar>();
|
||||
@@ -45,6 +45,10 @@ namespace Raindrop
|
||||
RegisterClientEvents(instance.Client);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnregisterClientEvents(instance.Client);
|
||||
}
|
||||
|
||||
private void RegisterClientEvents(GridClient client)
|
||||
{
|
||||
@@ -52,6 +56,13 @@ namespace Raindrop
|
||||
// client.Self.TeleportProgress += new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
|
||||
client.Network.SimDisconnected += new EventHandler<SimDisconnectedEventArgs>(Network_SimDisconnected);
|
||||
}
|
||||
|
||||
private void UnregisterClientEvents(GridClient client)
|
||||
{
|
||||
client.Grid.CoarseLocationUpdate -= new EventHandler<CoarseLocationUpdateEventArgs>(Grid_CoarseLocationUpdate);
|
||||
// client.Self.TeleportProgress -= new EventHandler<TeleportEventArgs>(Self_TeleportProgress);
|
||||
client.Network.SimDisconnected -= new EventHandler<SimDisconnectedEventArgs>(Network_SimDisconnected);
|
||||
}
|
||||
|
||||
#region eventHandlers
|
||||
void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
|
||||
|
||||
@@ -452,6 +452,12 @@ namespace Raindrop
|
||||
{
|
||||
MarkEndExecution();
|
||||
|
||||
if (_agentsTracker != null)
|
||||
{
|
||||
_agentsTracker.Dispose();
|
||||
_agentsTracker = null;
|
||||
}
|
||||
|
||||
if (Cof != null)
|
||||
{
|
||||
Cof.Dispose();
|
||||
|
||||
Reference in New Issue
Block a user