diff options
author | Charles Krinke | 2009-04-22 19:27:35 +0000 |
---|---|---|
committer | Charles Krinke | 2009-04-22 19:27:35 +0000 |
commit | 0f08f4cc4b10ec0e6ffa9bbce821a0d9ed7670e0 (patch) | |
tree | 286034015c9d3f33c7c603924191a9a42c91f96a /OpenSim/Client/MXP | |
parent | * Allow plugins to play nicely in UserManagerBase (diff) | |
download | opensim-SC-0f08f4cc4b10ec0e6ffa9bbce821a0d9ed7670e0.zip opensim-SC-0f08f4cc4b10ec0e6ffa9bbce821a0d9ed7670e0.tar.gz opensim-SC-0f08f4cc4b10ec0e6ffa9bbce821a0d9ed7670e0.tar.bz2 opensim-SC-0f08f4cc4b10ec0e6ffa9bbce821a0d9ed7670e0.tar.xz |
Thank you kindly, TLaukkan, for a patch that:
Adds connectivity to grid regions.
* Fixed UserService cast.
* Added exception handling to avoid mxp message handling
thread to exit and hang the module on unhandled exception.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Client/MXP/MXPModule.cs | 11 | ||||
-rw-r--r-- | OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | 153 |
2 files changed, 91 insertions, 73 deletions
diff --git a/OpenSim/Client/MXP/MXPModule.cs b/OpenSim/Client/MXP/MXPModule.cs index 082bcc3..dbe4174 100644 --- a/OpenSim/Client/MXP/MXPModule.cs +++ b/OpenSim/Client/MXP/MXPModule.cs | |||
@@ -83,13 +83,20 @@ namespace OpenSim.Client.MXP | |||
83 | 83 | ||
84 | m_ticker.Start(); | 84 | m_ticker.Start(); |
85 | 85 | ||
86 | m_log.Info("[MXP] MXP Enabled and Listening"); | 86 | m_log.Info("[MXP ClientStack] MXP Enabled and Listening"); |
87 | } | 87 | } |
88 | } | 88 | } |
89 | 89 | ||
90 | void ticker_Elapsed(object sender, ElapsedEventArgs e) | 90 | void ticker_Elapsed(object sender, ElapsedEventArgs e) |
91 | { | 91 | { |
92 | m_server.Process(); | 92 | try |
93 | { | ||
94 | m_server.Process(); | ||
95 | } | ||
96 | catch (Exception ex) | ||
97 | { | ||
98 | m_log.Error("[MXP ClientStack]: Unhandled exception in process loop: " + ex.ToString() + " :" + ex.StackTrace.ToString()); | ||
99 | } | ||
93 | 100 | ||
94 | if (!m_shutdown) | 101 | if (!m_shutdown) |
95 | m_ticker.Start(); | 102 | m_ticker.Start(); |
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs index 3333bbf..5167f42 100644 --- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs +++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs | |||
@@ -270,95 +270,104 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
270 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + | 270 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + |
271 | session.RemoteEndPoint.Port + ")"); | 271 | session.RemoteEndPoint.Port + ")"); |
272 | 272 | ||
273 | if (joinRequestMessage.BubbleId == Guid.Empty) | 273 | try |
274 | { | 274 | { |
275 | foreach (Scene scene in m_scenes.Values) | 275 | |
276 | if (joinRequestMessage.BubbleId == Guid.Empty) | ||
276 | { | 277 | { |
277 | if (scene.RegionInfo.RegionName == joinRequestMessage.BubbleName) | 278 | foreach (Scene scene in m_scenes.Values) |
278 | { | 279 | { |
279 | m_log.Info("[MXP ClientStack]: Resolved region by name: " + joinRequestMessage.BubbleName + " (" + scene.RegionInfo.RegionID + ")"); | 280 | if (scene.RegionInfo.RegionName == joinRequestMessage.BubbleName) |
280 | joinRequestMessage.BubbleId = scene.RegionInfo.RegionID.Guid; | 281 | { |
282 | m_log.Info("[MXP ClientStack]: Resolved region by name: " + joinRequestMessage.BubbleName + " (" + scene.RegionInfo.RegionID + ")"); | ||
283 | joinRequestMessage.BubbleId = scene.RegionInfo.RegionID.Guid; | ||
284 | } | ||
281 | } | 285 | } |
282 | } | 286 | } |
283 | } | ||
284 | 287 | ||
285 | if (joinRequestMessage.BubbleId == Guid.Empty) | 288 | if (joinRequestMessage.BubbleId == Guid.Empty) |
286 | { | 289 | { |
287 | m_log.Warn("[MXP ClientStack]: Failed to resolve region by name: " + joinRequestMessage.BubbleName); | 290 | m_log.Warn("[MXP ClientStack]: Failed to resolve region by name: " + joinRequestMessage.BubbleName); |
288 | } | 291 | } |
289 | |||
290 | UUID sceneId = new UUID(joinRequestMessage.BubbleId); | ||
291 | 292 | ||
292 | bool regionExists = true; | 293 | UUID sceneId = new UUID(joinRequestMessage.BubbleId); |
293 | if (!m_scenes.ContainsKey(sceneId)) | ||
294 | { | ||
295 | m_log.Info("[MXP ClientStack]: No such region: " + sceneId); | ||
296 | regionExists=false; | ||
297 | } | ||
298 | 294 | ||
299 | UserProfileData user=null; | 295 | bool regionExists = true; |
300 | UUID userId=UUID.Zero; | 296 | if (!m_scenes.ContainsKey(sceneId)) |
301 | string firstName=null; | 297 | { |
302 | string lastName=null; | 298 | m_log.Info("[MXP ClientStack]: No such region: " + sceneId); |
303 | bool authorized = regionExists?AuthoriseUser(joinRequestMessage.ParticipantName, | 299 | regionExists = false; |
304 | joinRequestMessage.ParticipantPassphrase, | 300 | } |
305 | new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user) | ||
306 | :false; | ||
307 | |||
308 | if (authorized) | ||
309 | { | ||
310 | Scene scene = m_scenes[sceneId]; | ||
311 | UUID mxpSessionID = UUID.Random(); | ||
312 | |||
313 | m_log.Debug("[MXP ClientStack]: Session join request success: " + session.SessionId + " (" + | ||
314 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + | ||
315 | session.RemoteEndPoint.Port + ")"); | ||
316 | 301 | ||
317 | m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile..."); | 302 | UserProfileData user = null; |
318 | AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); | 303 | UUID userId = UUID.Zero; |
319 | m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); | 304 | string firstName = null; |
320 | m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); | 305 | string lastName = null; |
321 | PrepareSceneForConnection(mxpSessionID, sceneId, user); | 306 | bool authorized = regionExists ? AuthoriseUser(joinRequestMessage.ParticipantName, |
322 | m_log.Debug("[MXP ClientStack]: Prepared Scene to Connection."); | 307 | joinRequestMessage.ParticipantPassphrase, |
323 | m_log.Debug("[MXP ClientStack]: Accepting connection..."); | 308 | new UUID(joinRequestMessage.BubbleId), out userId, out firstName, out lastName, out user) |
324 | AcceptConnection(session, joinRequestMessage, mxpSessionID, userId); | 309 | : false; |
325 | m_log.Info("[MXP ClientStack]: Accepted connection."); | ||
326 | 310 | ||
327 | m_log.Debug("[MXP ClientStack]: Creating ClientView...."); | 311 | if (authorized) |
328 | MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName); | 312 | { |
329 | m_clients.Add(client); | 313 | Scene scene = m_scenes[sceneId]; |
330 | m_log.Debug("[MXP ClientStack]: Created ClientView."); | 314 | UUID mxpSessionID = UUID.Random(); |
331 | 315 | ||
316 | m_log.Debug("[MXP ClientStack]: Session join request success: " + session.SessionId + " (" + | ||
317 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + | ||
318 | session.RemoteEndPoint.Port + ")"); | ||
332 | 319 | ||
333 | m_log.Debug("[MXP ClientStack]: Adding ClientView to Scene..."); | 320 | m_log.Debug("[MXP ClientStack]: Attaching UserAgent to UserProfile..."); |
334 | scene.ClientManager.Add(client.CircuitCode, client); | 321 | AttachUserAgentToUserProfile(session, mxpSessionID, sceneId, user); |
335 | m_log.Debug("[MXP ClientStack]: Added ClientView to Scene."); | 322 | m_log.Debug("[MXP ClientStack]: Attached UserAgent to UserProfile."); |
323 | m_log.Debug("[MXP ClientStack]: Preparing Scene to Connection..."); | ||
324 | PrepareSceneForConnection(mxpSessionID, sceneId, user); | ||
325 | m_log.Debug("[MXP ClientStack]: Prepared Scene to Connection."); | ||
326 | m_log.Debug("[MXP ClientStack]: Accepting connection..."); | ||
327 | AcceptConnection(session, joinRequestMessage, mxpSessionID, userId); | ||
328 | m_log.Info("[MXP ClientStack]: Accepted connection."); | ||
336 | 329 | ||
337 | 330 | m_log.Debug("[MXP ClientStack]: Creating ClientView...."); | |
338 | client.MXPSendSynchronizationBegin(m_scenes[new UUID(joinRequestMessage.BubbleId)].SceneContents.GetTotalObjectsCount()); | 331 | MXPClientView client = new MXPClientView(session, mxpSessionID, userId, scene, firstName, lastName); |
332 | m_clients.Add(client); | ||
333 | m_log.Debug("[MXP ClientStack]: Created ClientView."); | ||
339 | 334 | ||
340 | m_log.Debug("[MXP ClientStack]: Starting ClientView..."); | 335 | |
341 | try | 336 | m_log.Debug("[MXP ClientStack]: Adding ClientView to Scene..."); |
342 | { | 337 | scene.ClientManager.Add(client.CircuitCode, client); |
343 | client.Start(); | 338 | m_log.Debug("[MXP ClientStack]: Added ClientView to Scene."); |
344 | m_log.Debug("[MXP ClientStack]: Started ClientView."); | 339 | |
340 | |||
341 | client.MXPSendSynchronizationBegin(m_scenes[new UUID(joinRequestMessage.BubbleId)].SceneContents.GetTotalObjectsCount()); | ||
342 | |||
343 | m_log.Debug("[MXP ClientStack]: Starting ClientView..."); | ||
344 | try | ||
345 | { | ||
346 | client.Start(); | ||
347 | m_log.Debug("[MXP ClientStack]: Started ClientView."); | ||
348 | } | ||
349 | catch (Exception e) | ||
350 | { | ||
351 | m_log.Error(e); | ||
352 | } | ||
353 | |||
354 | m_log.Debug("[MXP ClientStack]: Connected"); | ||
345 | } | 355 | } |
346 | catch (Exception e) | 356 | else |
347 | { | 357 | { |
348 | m_log.Error(e); | 358 | m_log.Info("[MXP ClientStack]: Session join request failure: " + session.SessionId + " (" + |
349 | } | 359 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + |
360 | session.RemoteEndPoint.Port + ")"); | ||
350 | 361 | ||
351 | m_log.Debug("[MXP ClientStack]: Connected"); | 362 | DeclineConnection(session, joinRequestMessage); |
363 | } | ||
352 | } | 364 | } |
353 | else | 365 | catch (Exception e) |
354 | { | 366 | { |
355 | m_log.Info("[MXP ClientStack]: Session join request failure: " + session.SessionId + " (" + | 367 | m_log.Error("[MXP ClientStack]: Session join request failure: " + session.SessionId + " (" + |
356 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + | 368 | (session.IsIncoming ? "from" : "to") + " " + session.RemoteEndPoint.Address + ":" + |
357 | session.RemoteEndPoint.Port + ")"); | 369 | session.RemoteEndPoint.Port + "): "+e.ToString()+" :"+e.StackTrace.ToString()); |
358 | |||
359 | DeclineConnection(session, joinRequestMessage); | ||
360 | } | 370 | } |
361 | |||
362 | tmpRemove.Add(session); | 371 | tmpRemove.Add(session); |
363 | } | 372 | } |
364 | } | 373 | } |
@@ -528,7 +537,7 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
528 | { | 537 | { |
529 | //Scene scene = m_scenes[sceneId]; | 538 | //Scene scene = m_scenes[sceneId]; |
530 | CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; | 539 | CommunicationsManager commsManager = m_scenes[sceneId].CommsManager; |
531 | UserManagerBase userService = (UserManagerBase)commsManager.UserService; | 540 | IUserService userService = (IUserService)commsManager.UserService; |
532 | 541 | ||
533 | UserAgentData agent = new UserAgentData(); | 542 | UserAgentData agent = new UserAgentData(); |
534 | 543 | ||
@@ -565,7 +574,9 @@ namespace OpenSim.Client.MXP.PacketHandler | |||
565 | 574 | ||
566 | userProfile.CurrentAgent = agent; | 575 | userProfile.CurrentAgent = agent; |
567 | 576 | ||
568 | userService.CommitAgent(ref userProfile); | 577 | |
578 | userService.UpdateUserProfile(userProfile); | ||
579 | //userService.CommitAgent(ref userProfile); | ||
569 | } | 580 | } |
570 | 581 | ||
571 | private void PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile) | 582 | private void PrepareSceneForConnection(UUID sessionId, UUID sceneId, UserProfileData userProfile) |