aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
diff options
context:
space:
mode:
authorMelanie2010-01-19 04:18:01 +0000
committerMelanie2010-01-19 04:18:01 +0000
commita3f48a7ca66347b11990e5444a636d40bec5dbf1 (patch)
treea5708996ccf28ce8696b8257a0b33352f56e2afe /OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
parentAdd a Hyperlink flag to the regions table (diff)
parent* Towards enabling hyperlinks at grid-level. (diff)
downloadopensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.zip
opensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.gz
opensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.bz2
opensim-SC_OLD-a3f48a7ca66347b11990e5444a636d40bec5dbf1.tar.xz
Merge branch 'presence-refactor' of melanie@opensimulator.org:/var/git/opensim into presence-refactor
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs118
1 files changed, 116 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 101aea0..d39537d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -34,6 +34,7 @@ using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Services.Connectors.Hypergrid; 35using OpenSim.Services.Connectors.Hypergrid;
36using OpenSim.Services.Interfaces; 36using OpenSim.Services.Interfaces;
37using OpenSim.Server.Base;
37 38
38using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
@@ -59,6 +60,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
59 } 60 }
60 61
61 private GatekeeperServiceConnector m_GatekeeperConnector; 62 private GatekeeperServiceConnector m_GatekeeperConnector;
63 private IHomeUsersSecurityService m_Security;
62 64
63 #region ISharedRegionModule 65 #region ISharedRegionModule
64 66
@@ -77,12 +79,42 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
77 { 79 {
78 m_agentsInTransit = new List<UUID>(); 80 m_agentsInTransit = new List<UUID>();
79 m_GatekeeperConnector = new GatekeeperServiceConnector(); 81 m_GatekeeperConnector = new GatekeeperServiceConnector();
82
83 IConfig config = source.Configs["HGEntityTransferModule"];
84 if (config != null)
85 {
86 string dll = config.GetString("HomeUsersSecurityService", string.Empty);
87 if (dll != string.Empty)
88 {
89 Object[] args = new Object[] { source };
90 m_Security = ServerUtils.LoadPlugin<IHomeUsersSecurityService>(dll, args);
91 if (m_Security == null)
92 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Unable to load Home Users Security service");
93 else
94 m_log.Debug("[HG ENTITY TRANSFER MODULE]: Home Users Security service loaded");
95 }
96 }
97
80 m_Enabled = true; 98 m_Enabled = true;
81 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); 99 m_log.InfoFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name);
82 } 100 }
83 } 101 }
84 } 102 }
85 103
104 public override void AddRegion(Scene scene)
105 {
106 base.AddRegion(scene);
107 if (m_Enabled)
108 scene.RegisterModuleInterface<IHomeUsersSecurityService>(m_Security);
109 }
110
111 public override void RemoveRegion(Scene scene)
112 {
113 base.AddRegion(scene);
114 if (m_Enabled)
115 scene.UnregisterModuleInterface<IHomeUsersSecurityService>(m_Security);
116 }
117
86 118
87 #endregion 119 #endregion
88 120
@@ -98,19 +130,101 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
98 return true; 130 return true;
99 } 131 }
100 132
101 protected override bool CreateAgent(GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason) 133 protected override bool CreateAgent(ScenePresence sp, GridRegion reg, GridRegion finalDestination, AgentCircuitData agentCircuit, uint teleportFlags, out string reason)
102 { 134 {
103 reason = string.Empty; 135 reason = string.Empty;
104 if (reg.RegionLocX != finalDestination.RegionLocX && reg.RegionLocY != finalDestination.RegionLocY) 136 if (reg.RegionLocX != finalDestination.RegionLocX || reg.RegionLocY != finalDestination.RegionLocY)
105 { 137 {
106 // this user is going to another grid 138 // this user is going to another grid
107 reg.RegionName = finalDestination.RegionName; 139 reg.RegionName = finalDestination.RegionName;
140 reg.RegionID = finalDestination.RegionID;
141 reg.RegionLocX = finalDestination.RegionLocX;
142 reg.RegionLocY = finalDestination.RegionLocY;
143
144 // Log their session and remote endpoint in the home users security service
145 IHomeUsersSecurityService security = sp.Scene.RequestModuleInterface<IHomeUsersSecurityService>();
146 if (security != null)
147 security.SetEndPoint(sp.ControllingClient.SessionId, sp.ControllingClient.RemoteEndPoint);
148
149 // Log them out of this grid
150 sp.Scene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
151
108 return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 152 return m_GatekeeperConnector.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
109 } 153 }
110 154
111 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason); 155 return m_aScene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason);
112 } 156 }
113 157
158 public override void TeleportHome(UUID id, IClientAPI client)
159 {
160 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
161
162 // Let's find out if this is a foreign user or a local user
163 UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, id);
164 if (account != null)
165 {
166 // local grid user
167 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: User is local");
168 base.TeleportHome(id, client);
169 return;
170 }
171
172 // Foreign user wants to go home
173 //
174 AgentCircuitData aCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
175 if (aCircuit == null || (aCircuit != null && !aCircuit.ServiceURLs.ContainsKey("GatewayURI")))
176 {
177 client.SendTeleportFailed("Your information has been lost");
178 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Unable to locate agent's gateway information");
179 return;
180 }
181
182 GridRegion homeGatekeeper = MakeRegion(aCircuit);
183 if (homeGatekeeper == null)
184 {
185 client.SendTeleportFailed("Your information has been lost");
186 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's gateway information is malformed");
187 return;
188 }
189
190 Vector3 position = Vector3.UnitY, lookAt = Vector3.UnitY;
191 GridRegion finalDestination = m_GatekeeperConnector.GetHomeRegion(homeGatekeeper, aCircuit.AgentID, out position, out lookAt);
192 if (finalDestination == null)
193 {
194 client.SendTeleportFailed("Your home region could not be found");
195 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent's home region not found");
196 return;
197 }
198
199 ScenePresence sp = ((Scene)(client.Scene)).GetScenePresence(client.AgentId);
200 if (sp == null)
201 {
202 client.SendTeleportFailed("Internal error");
203 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Agent not found in the scene where it is supposed to be");
204 return;
205 }
206
207 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: teleporting user {0} {1} home to {2} via {3}:{4}:{5}",
208 aCircuit.firstname, aCircuit.lastname, finalDestination.RegionName, homeGatekeeper.ExternalHostName, homeGatekeeper.HttpPort, homeGatekeeper.RegionName);
209
210 IEventQueue eq = sp.Scene.RequestModuleInterface<IEventQueue>();
211 DoTeleport(sp, homeGatekeeper, finalDestination, position, lookAt, (uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome), eq);
212 }
114 #endregion 213 #endregion
214
215 private GridRegion MakeRegion(AgentCircuitData aCircuit)
216 {
217 GridRegion region = new GridRegion();
218
219 Uri uri = null;
220 if (!Uri.TryCreate(aCircuit.ServiceURLs["GatewayURI"].ToString(), UriKind.Absolute, out uri))
221 return null;
222
223 region.ExternalHostName = uri.Host;
224 region.HttpPort = (uint)uri.Port;
225 region.RegionName = string.Empty;
226 region.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), (int)0);
227 return region;
228 }
115 } 229 }
116} 230}