aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/UserLoginService.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 16:41:01 +0000
committerAdam Frisby2008-05-01 16:41:01 +0000
commitfc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8 (patch)
tree90a4799fa43e3761ffbe669d1d87837933d8db53 /OpenSim/Grid/UserServer/UserLoginService.cs
parent* Deletes my EventReader ScriptRewriter. It isn't required to rewrite the sc... (diff)
downloadopensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.zip
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.gz
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.bz2
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.xz
* Cleaning code still.
Diffstat (limited to 'OpenSim/Grid/UserServer/UserLoginService.cs')
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs118
1 files changed, 62 insertions, 56 deletions
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index b123b8c..b19b74d 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -41,26 +41,26 @@ using OpenSim.Framework.Servers;
41namespace OpenSim.Grid.UserServer 41namespace OpenSim.Grid.UserServer
42{ 42{
43 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 43 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
44 ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname); 44 ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname);
45 45
46 public class UserLoginService : LoginService 46 public class UserLoginService : LoginService
47 { 47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 public event UserLoggedInAtLocation OnUserLoggedInAtLocation; 50 private UserLoggedInAtLocation handlerUserLoggedInAtLocation;
51 51
52 private UserLoggedInAtLocation handlerUserLoggedInAtLocation = null;
53
54 public UserConfig m_config; 52 public UserConfig m_config;
55 53
56 public UserLoginService( 54 public UserLoginService(
57 UserManagerBase userManager, LibraryRootFolder libraryRootFolder, 55 UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
58 UserConfig config, string welcomeMess) 56 UserConfig config, string welcomeMess)
59 : base(userManager, libraryRootFolder, welcomeMess) 57 : base(userManager, libraryRootFolder, welcomeMess)
60 { 58 {
61 m_config = config; 59 m_config = config;
62 } 60 }
63 61
62 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
63
64 /// <summary> 64 /// <summary>
65 /// Customises the login response and fills in missing values. 65 /// Customises the login response and fills in missing values.
66 /// </summary> 66 /// </summary>
@@ -95,7 +95,8 @@ namespace OpenSim.Grid.UserServer
95 else 95 else
96 { 96 {
97 string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest); 97 string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest);
98 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]); 98 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" +
99 startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]);
99 if (startLocationRequestParsed[0] == "last") 100 if (startLocationRequestParsed[0] == "last")
100 { 101 {
101 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z' 102 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z'
@@ -108,9 +109,9 @@ namespace OpenSim.Grid.UserServer
108 { 109 {
109 m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]); 110 m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]);
110 SimInfo = 111 SimInfo =
111 RegionProfileData.RequestSimProfileData( 112 RegionProfileData.RequestSimProfileData(
112 startLocationRequestParsed[0], m_config.GridServerURL, 113 startLocationRequestParsed[0], m_config.GridServerURL,
113 m_config.GridSendKey, m_config.GridRecvKey); 114 m_config.GridSendKey, m_config.GridRecvKey);
114 115
115 if (SimInfo == null) 116 if (SimInfo == null)
116 { 117 {
@@ -119,7 +120,9 @@ namespace OpenSim.Grid.UserServer
119 RegionProfileData.RequestSimProfileData( 120 RegionProfileData.RequestSimProfileData(
120 theUser.HomeRegion, m_config.GridServerURL, 121 theUser.HomeRegion, m_config.GridServerURL,
121 m_config.GridSendKey, m_config.GridRecvKey); 122 m_config.GridSendKey, m_config.GridRecvKey);
122 } else { 123 }
124 else
125 {
123 start_x = Convert.ToInt32(startLocationRequestParsed[1]); 126 start_x = Convert.ToInt32(startLocationRequestParsed[1]);
124 start_y = Convert.ToInt32(startLocationRequestParsed[2]); 127 start_y = Convert.ToInt32(startLocationRequestParsed[2]);
125 start_z = Convert.ToInt32(startLocationRequestParsed[3]); 128 start_z = Convert.ToInt32(startLocationRequestParsed[3]);
@@ -130,30 +133,30 @@ namespace OpenSim.Grid.UserServer
130 // Customise the response 133 // Customise the response
131 //CFK: This is redundant and the next message should always appear. 134 //CFK: This is redundant and the next message should always appear.
132 //CFK: m_log.Info("[LOGIN]: Home Location"); 135 //CFK: m_log.Info("[LOGIN]: Home Location");
133 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + 136 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" +
134 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " + 137 (SimInfo.regionLocY * Constants.RegionSize) + "], " +
135 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" + 138 "'position':[r" + theUser.HomeLocation.X + ",r" +
136 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " + 139 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " +
137 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" + 140 "'look_at':[r" + theUser.HomeLocation.X + ",r" +
138 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}"; 141 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}";
139 142
140 // Destination 143 // Destination
141 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 144 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
142 //CFK: the next one for X & Y and comment this one. 145 //CFK: the next one for X & Y and comment this one.
143 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + 146 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
144 //CFK: "; Region Y: " + SimInfo.regionLocY); 147 //CFK: "; Region Y: " + SimInfo.regionLocY);
145 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString(); 148 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString();
146 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]); 149 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]);
147 response.RegionX = SimInfo.regionLocX; 150 response.RegionX = SimInfo.regionLocX;
148 response.RegionY = SimInfo.regionLocY; 151 response.RegionY = SimInfo.regionLocY;
149 152
150 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI 153 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
151 string capsPath = Util.GetRandomCapsPath(); 154 string capsPath = Util.GetRandomCapsPath();
152 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; 155 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
153 156
154 m_log.DebugFormat( 157 m_log.DebugFormat(
155 "[LOGIN]: Sending new CAPS seed url {0} to client {1}", 158 "[LOGIN]: Sending new CAPS seed url {0} to client {1}",
156 response.SeedCapability, response.AgentID); 159 response.SeedCapability, response.AgentID);
157 160
158 // Notify the target of an incoming user 161 // Notify the target of an incoming user
159 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 162 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
@@ -163,7 +166,8 @@ namespace OpenSim.Grid.UserServer
163 166
164 theUser.CurrentAgent.Region = SimInfo.UUID; 167 theUser.CurrentAgent.Region = SimInfo.UUID;
165 theUser.CurrentAgent.Handle = SimInfo.regionHandle; 168 theUser.CurrentAgent.Handle = SimInfo.regionHandle;
166 if (start_x >= 0 && start_y >= 0 && start_z >= 0) { 169 if (start_x >= 0 && start_y >= 0 && start_z >= 0)
170 {
167 LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z); 171 LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z);
168 theUser.CurrentAgent.Position = tmp_v; 172 theUser.CurrentAgent.Position = tmp_v;
169 } 173 }
@@ -186,42 +190,43 @@ namespace OpenSim.Grid.UserServer
186 // Update agent with target sim 190 // Update agent with target sim
187 191
188 m_log.InfoFormat( 192 m_log.InfoFormat(
189 "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection", 193 "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection",
190 SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI); 194 SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI);
191 195
192 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); 196 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
193 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 197 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
194 198
195 if (GridResp.IsFault) 199 if (GridResp.IsFault)
196 { 200 {
197 m_log.ErrorFormat( 201 m_log.ErrorFormat(
198 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}", 202 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}",
199 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 203 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
200 } 204 }
201 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; 205 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
202 if (handlerUserLoggedInAtLocation != null) 206 if (handlerUserLoggedInAtLocation != null)
203 { 207 {
204 //m_log.Info("[LOGIN]: Letting other objects know about login"); 208 //m_log.Info("[LOGIN]: Letting other objects know about login");
205 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, 209 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region,
206 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X,theUser.CurrentAgent.Position.Y,theUser.CurrentAgent.Position.Z, 210 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y,
207 theUser.FirstName,theUser.SurName); 211 theUser.CurrentAgent.Position.Z,
212 theUser.FirstName, theUser.SurName);
208 } 213 }
209 } 214 }
210 catch (Exception) 215 catch (Exception)
211 //catch (System.AccessViolationException) 216 //catch (System.AccessViolationException)
212 { 217 {
213 tryDefault = true; 218 tryDefault = true;
214 } 219 }
215 220
216 if (tryDefault) 221 if (tryDefault)
217 { 222 {
218 // Send him to default region instead 223 // Send him to default region instead
219 // Load information from the gridserver 224 // Load information from the gridserver
220 225
221 ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize); 226 ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong) m_config.DefaultY * Constants.RegionSize);
222 227
223 m_log.Warn( 228 m_log.Warn(
224 "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString()); 229 "[LOGIN]: Home region not available: sending to default " + defaultHandle);
225 230
226 try 231 try
227 { 232 {
@@ -231,19 +236,19 @@ namespace OpenSim.Grid.UserServer
231 236
232 // Customise the response 237 // Customise the response
233 m_log.Info("[LOGIN]: Home Location"); 238 m_log.Info("[LOGIN]: Home Location");
234 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" + 239 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" +
235 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " + 240 (SimInfo.regionLocY * Constants.RegionSize) + "], " +
236 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" + 241 "'position':[r" + theUser.HomeLocation.X + ",r" +
237 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " + 242 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " +
238 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" + 243 "'look_at':[r" + theUser.HomeLocation.X + ",r" +
239 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}"; 244 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}";
240 245
241 // Destination 246 // Destination
242 m_log.Info("[LOGIN]: " + 247 m_log.Info("[LOGIN]: " +
243 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + 248 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
244 SimInfo.regionLocY); 249 SimInfo.regionLocY);
245 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString(); 250 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString();
246 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]); 251 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]);
247 response.RegionX = SimInfo.regionLocX; 252 response.RegionX = SimInfo.regionLocX;
248 response.RegionY = SimInfo.regionLocY; 253 response.RegionY = SimInfo.regionLocY;
249 254
@@ -283,15 +288,16 @@ namespace OpenSim.Grid.UserServer
283 { 288 {
284 m_log.Info("[LOGIN]: Letting other objects know about login"); 289 m_log.Info("[LOGIN]: Letting other objects know about login");
285 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, 290 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region,
286 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, theUser.CurrentAgent.Position.Z, 291 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y,
287 theUser.FirstName, theUser.SurName); 292 theUser.CurrentAgent.Position.Z,
293 theUser.FirstName, theUser.SurName);
288 } 294 }
289 } 295 }
290 296
291 catch (Exception e) 297 catch (Exception e)
292 { 298 {
293 m_log.Warn("[LOGIN]: Default region also not available"); 299 m_log.Warn("[LOGIN]: Default region also not available");
294 m_log.Warn("[LOGIN]: " + e.ToString()); 300 m_log.Warn("[LOGIN]: " + e);
295 } 301 }
296 } 302 }
297 } 303 }
@@ -300,8 +306,8 @@ namespace OpenSim.Grid.UserServer
300 protected override InventoryData GetInventorySkeleton(LLUUID userID) 306 protected override InventoryData GetInventorySkeleton(LLUUID userID)
301 { 307 {
302 m_log.DebugFormat( 308 m_log.DebugFormat(
303 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}", 309 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}",
304 m_config.InventoryUrl, userID); 310 m_config.InventoryUrl, userID);
305 311
306 List<InventoryFolderBase> folders 312 List<InventoryFolderBase> folders
307 = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( 313 = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
@@ -316,23 +322,23 @@ namespace OpenSim.Grid.UserServer
316 // tools are creating the user profile directly in the database without creating the inventory. At 322 // tools are creating the user profile directly in the database without creating the inventory. At
317 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already 323 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already
318 // exist. 324 // exist.
319 bool created = 325 bool created =
320 SynchronousRestObjectPoster.BeginPostObject<Guid, bool>( 326 SynchronousRestObjectPoster.BeginPostObject<Guid, bool>(
321 "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID); 327 "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID);
322 328
323 if (!created) 329 if (!created)
324 { 330 {
325 throw new Exception( 331 throw new Exception(
326 String.Format( 332 String.Format(
327 "The inventory creation request for user {0} did not succeed." 333 "The inventory creation request for user {0} did not succeed."
328 + " Please contact your inventory service provider for more information.", 334 + " Please contact your inventory service provider for more information.",
329 userID)); 335 userID));
330 } 336 }
331 else 337 else
332 { 338 {
333 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); 339 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
334 } 340 }
335 341
336 folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( 342 folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
337 "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); 343 "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID);
338 } 344 }
@@ -342,11 +348,11 @@ namespace OpenSim.Grid.UserServer
342 LLUUID rootID = LLUUID.Zero; 348 LLUUID rootID = LLUUID.Zero;
343 ArrayList AgentInventoryArray = new ArrayList(); 349 ArrayList AgentInventoryArray = new ArrayList();
344 Hashtable TempHash; 350 Hashtable TempHash;
345 351
346 foreach (InventoryFolderBase InvFolder in folders) 352 foreach (InventoryFolderBase InvFolder in folders)
347 { 353 {
348// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); 354// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name);
349 355
350 if (InvFolder.ParentID == LLUUID.Zero) 356 if (InvFolder.ParentID == LLUUID.Zero)
351 { 357 {
352 rootID = InvFolder.ID; 358 rootID = InvFolder.ID;
@@ -359,16 +365,16 @@ namespace OpenSim.Grid.UserServer
359 TempHash["folder_id"] = InvFolder.ID.ToString(); 365 TempHash["folder_id"] = InvFolder.ID.ToString();
360 AgentInventoryArray.Add(TempHash); 366 AgentInventoryArray.Add(TempHash);
361 } 367 }
362 368
363 return new InventoryData(AgentInventoryArray, rootID); 369 return new InventoryData(AgentInventoryArray, rootID);
364 } 370 }
365 else 371 else
366 { 372 {
367 throw new Exception( 373 throw new Exception(
368 String.Format( 374 String.Format(
369 "A root inventory folder for user {0} could not be retrieved from the inventory service", 375 "A root inventory folder for user {0} could not be retrieved from the inventory service",
370 userID)); 376 userID));
371 } 377 }
372 } 378 }
373 } 379 }
374} 380} \ No newline at end of file