12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- using System;
- using System.Collections.Generic;
- using OpenMetaverse;
- using OpenSim.Region.Framework.Scenes;
- namespace OpenSim.Region.RegionCombinerModule
- {
- public class RegionCombinerClientEventForwarder
- {
- private Scene m_rootScene;
- private Dictionary<UUID, Scene> m_virtScene = new Dictionary<UUID, Scene>();
- private Dictionary<UUID,RegionCombinerIndividualEventForwarder> m_forwarders = new Dictionary<UUID,
- RegionCombinerIndividualEventForwarder>();
- public RegionCombinerClientEventForwarder(RegionConnections rootScene)
- {
- m_rootScene = rootScene.RegionScene;
- }
- public void AddSceneToEventForwarding(Scene virtualScene)
- {
- lock (m_virtScene)
- {
- if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID))
- {
- m_virtScene[virtualScene.RegionInfo.originRegionID] = virtualScene;
- }
- else
- {
- m_virtScene.Add(virtualScene.RegionInfo.originRegionID, virtualScene);
- }
- }
-
- lock (m_forwarders)
- {
-
- if (m_forwarders.ContainsKey(virtualScene.RegionInfo.originRegionID))
- m_forwarders.Remove(virtualScene.RegionInfo.originRegionID);
- RegionCombinerIndividualEventForwarder forwarder =
- new RegionCombinerIndividualEventForwarder(m_rootScene, virtualScene);
- m_forwarders.Add(virtualScene.RegionInfo.originRegionID, forwarder);
- virtualScene.EventManager.OnNewClient += forwarder.ClientConnect;
- virtualScene.EventManager.OnClientClosed += forwarder.ClientClosed;
- }
- }
- public void RemoveSceneFromEventForwarding (Scene virtualScene)
- {
- lock (m_forwarders)
- {
- RegionCombinerIndividualEventForwarder forwarder = m_forwarders[virtualScene.RegionInfo.originRegionID];
- virtualScene.EventManager.OnNewClient -= forwarder.ClientConnect;
- virtualScene.EventManager.OnClientClosed -= forwarder.ClientClosed;
- m_forwarders.Remove(virtualScene.RegionInfo.originRegionID);
- }
- lock (m_virtScene)
- {
- if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID))
- {
- m_virtScene.Remove(virtualScene.RegionInfo.originRegionID);
- }
- }
- }
- }
- }
|