diff options
Diffstat (limited to 'OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs')
-rw-r--r-- | OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs | 679 |
1 files changed, 0 insertions, 679 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs index ea8ac2e..36d4b99 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesStandalone.cs | |||
@@ -84,7 +84,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
84 | httpServer.AddXmlRPCHandler("check", PingCheckReply); | 84 | httpServer.AddXmlRPCHandler("check", PingCheckReply); |
85 | httpServer.AddXmlRPCHandler("land_data", LandData); | 85 | httpServer.AddXmlRPCHandler("land_data", LandData); |
86 | 86 | ||
87 | StartRemoting(); | ||
88 | } | 87 | } |
89 | 88 | ||
90 | #region IGridServices interface | 89 | #region IGridServices interface |
@@ -256,683 +255,5 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
256 | 255 | ||
257 | #endregion | 256 | #endregion |
258 | 257 | ||
259 | #region Remoting | ||
260 | |||
261 | /// <summary> | ||
262 | /// Start listening for .net remoting calls from other regions. | ||
263 | /// </summary> | ||
264 | private void StartRemoting() | ||
265 | { | ||
266 | m_log.Info("[HGrid]: Start remoting..."); | ||
267 | TcpChannel ch; | ||
268 | try | ||
269 | { | ||
270 | ch = new TcpChannel((int)NetworkServersInfo.RemotingListenerPort); | ||
271 | ChannelServices.RegisterChannel(ch, false); // Disabled security as Mono doesn't support this. | ||
272 | } | ||
273 | catch (Exception ex) | ||
274 | { | ||
275 | m_log.Error("[HGrid]: Exception while attempting to listen on TCP port " + (int)NetworkServersInfo.RemotingListenerPort + "."); | ||
276 | throw (ex); | ||
277 | } | ||
278 | |||
279 | WellKnownServiceTypeEntry wellType = | ||
280 | new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", | ||
281 | WellKnownObjectMode.Singleton); | ||
282 | RemotingConfiguration.RegisterWellKnownServiceType(wellType); | ||
283 | InterRegionSingleton.Instance.OnArrival += TriggerExpectAvatarCrossing; | ||
284 | InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; | ||
285 | InterRegionSingleton.Instance.OnPrimGroupArrival += IncomingPrim; | ||
286 | InterRegionSingleton.Instance.OnPrimGroupNear += TriggerExpectPrimCrossing; | ||
287 | InterRegionSingleton.Instance.OnRegionUp += TriggerRegionUp; | ||
288 | InterRegionSingleton.Instance.OnChildAgentUpdate += TriggerChildAgentUpdate; | ||
289 | InterRegionSingleton.Instance.OnTellRegionToCloseChildConnection += TriggerTellRegionToCloseChildConnection; | ||
290 | } | ||
291 | |||
292 | |||
293 | #endregion | ||
294 | |||
295 | #region IInterRegionCommunications interface (Methods called by regions in this instance) | ||
296 | |||
297 | public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) | ||
298 | { | ||
299 | int failures = 0; | ||
300 | lock (m_deadRegionCache) | ||
301 | { | ||
302 | if (m_deadRegionCache.ContainsKey(regionHandle)) | ||
303 | { | ||
304 | failures = m_deadRegionCache[regionHandle]; | ||
305 | } | ||
306 | } | ||
307 | if (failures <= 3) | ||
308 | { | ||
309 | RegionInfo regInfo = null; | ||
310 | try | ||
311 | { | ||
312 | if (m_localBackend.ChildAgentUpdate(regionHandle, cAgentData)) | ||
313 | { | ||
314 | return true; | ||
315 | } | ||
316 | |||
317 | regInfo = RequestNeighbourInfo(regionHandle); | ||
318 | if (regInfo != null) | ||
319 | { | ||
320 | //don't want to be creating a new link to the remote instance every time like we are here | ||
321 | bool retValue = false; | ||
322 | |||
323 | |||
324 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
325 | typeof(OGS1InterRegionRemoting), | ||
326 | "tcp://" + regInfo.RemotingAddress + | ||
327 | ":" + regInfo.RemotingPort + | ||
328 | "/InterRegions"); | ||
329 | |||
330 | if (remObject != null) | ||
331 | { | ||
332 | retValue = remObject.ChildAgentUpdate(regionHandle, cAgentData); | ||
333 | } | ||
334 | else | ||
335 | { | ||
336 | m_log.Warn("[HGrid]: remoting object not found"); | ||
337 | } | ||
338 | remObject = null; | ||
339 | |||
340 | return retValue; | ||
341 | } | ||
342 | NoteDeadRegion(regionHandle); | ||
343 | |||
344 | return false; | ||
345 | } | ||
346 | catch (RemotingException e) | ||
347 | { | ||
348 | NoteDeadRegion(regionHandle); | ||
349 | |||
350 | m_log.WarnFormat( | ||
351 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
352 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
353 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
354 | |||
355 | return false; | ||
356 | } | ||
357 | catch (SocketException e) | ||
358 | { | ||
359 | NoteDeadRegion(regionHandle); | ||
360 | |||
361 | m_log.WarnFormat( | ||
362 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
363 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
364 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
365 | |||
366 | return false; | ||
367 | } | ||
368 | catch (InvalidCredentialException e) | ||
369 | { | ||
370 | NoteDeadRegion(regionHandle); | ||
371 | |||
372 | m_log.WarnFormat( | ||
373 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
374 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
375 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
376 | |||
377 | return false; | ||
378 | } | ||
379 | catch (AuthenticationException e) | ||
380 | { | ||
381 | NoteDeadRegion(regionHandle); | ||
382 | |||
383 | m_log.WarnFormat( | ||
384 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
385 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
386 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
387 | |||
388 | return false; | ||
389 | } | ||
390 | catch (Exception e) | ||
391 | { | ||
392 | NoteDeadRegion(regionHandle); | ||
393 | |||
394 | m_log.WarnFormat("[HGrid]: Unable to connect to adjacent region: {0} {1},{2}", | ||
395 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
396 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
397 | |||
398 | return false; | ||
399 | } | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | //m_log.Info("[INTERREGION]: Skipped Sending Child Update to a region because it failed too many times:" + regionHandle.ToString()); | ||
404 | return false; | ||
405 | } | ||
406 | } | ||
407 | |||
408 | /// <summary> | ||
409 | /// Inform a region that a child agent will be on the way from a client. | ||
410 | /// </summary> | ||
411 | /// <param name="regionHandle"></param> | ||
412 | /// <param name="agentData"></param> | ||
413 | /// <returns></returns> | ||
414 | public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
415 | { | ||
416 | |||
417 | if (m_localBackend.InformRegionOfChildAgent(regionHandle, agentData)) | ||
418 | { | ||
419 | return true; | ||
420 | } | ||
421 | return base.InformRegionOfChildAgent(regionHandle, agentData); | ||
422 | } | ||
423 | |||
424 | // UGLY! | ||
425 | public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle) | ||
426 | { | ||
427 | if (m_localBackend.RegionUp(region, regionhandle)) | ||
428 | return true; | ||
429 | return base.RegionUp(region, regionhandle); | ||
430 | } | ||
431 | |||
432 | /// <summary> | ||
433 | /// | ||
434 | /// </summary> | ||
435 | /// <param name="regionHandle"></param> | ||
436 | /// <param name="agentData"></param> | ||
437 | /// <returns></returns> | ||
438 | public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) | ||
439 | { | ||
440 | int failures = 0; | ||
441 | lock (m_deadRegionCache) | ||
442 | { | ||
443 | if (m_deadRegionCache.ContainsKey(regionHandle)) | ||
444 | { | ||
445 | failures = m_deadRegionCache[regionHandle]; | ||
446 | } | ||
447 | } | ||
448 | if (failures <= 1) | ||
449 | { | ||
450 | RegionInfo regInfo = null; | ||
451 | try | ||
452 | { | ||
453 | if (m_localBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod)) | ||
454 | { | ||
455 | return true; | ||
456 | } | ||
457 | |||
458 | regInfo = RequestNeighbourInfo(regionHandle); | ||
459 | if (regInfo != null) | ||
460 | { | ||
461 | try | ||
462 | { | ||
463 | regionHandle = Convert.ToUInt64(regInfo.regionSecret); | ||
464 | } | ||
465 | catch (Exception) | ||
466 | { | ||
467 | m_log.Warn("[HGrid]: Invalid hyperlink region."); | ||
468 | return false; | ||
469 | } | ||
470 | |||
471 | //don't want to be creating a new link to the remote instance every time like we are here | ||
472 | bool retValue = false; | ||
473 | |||
474 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
475 | typeof(OGS1InterRegionRemoting), | ||
476 | "tcp://" + regInfo.RemotingAddress + | ||
477 | ":" + regInfo.RemotingPort + | ||
478 | "/InterRegions"); | ||
479 | |||
480 | if (remObject != null) | ||
481 | { | ||
482 | m_log.Debug("[HGrid]: Inform region of prim crossing: " + regInfo.RemotingAddress + ":" + regInfo.RemotingPort); | ||
483 | retValue = remObject.InformRegionOfPrimCrossing(regionHandle, primID.Guid, objData, XMLMethod); | ||
484 | } | ||
485 | else | ||
486 | { | ||
487 | m_log.Warn("[HGrid]: Remoting object not found"); | ||
488 | } | ||
489 | remObject = null; | ||
490 | |||
491 | return retValue; | ||
492 | } | ||
493 | NoteDeadRegion(regionHandle); | ||
494 | return false; | ||
495 | } | ||
496 | catch (RemotingException e) | ||
497 | { | ||
498 | NoteDeadRegion(regionHandle); | ||
499 | m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); | ||
500 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
501 | return false; | ||
502 | } | ||
503 | catch (SocketException e) | ||
504 | { | ||
505 | NoteDeadRegion(regionHandle); | ||
506 | m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); | ||
507 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
508 | return false; | ||
509 | } | ||
510 | catch (InvalidCredentialException e) | ||
511 | { | ||
512 | NoteDeadRegion(regionHandle); | ||
513 | m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); | ||
514 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
515 | return false; | ||
516 | } | ||
517 | catch (AuthenticationException e) | ||
518 | { | ||
519 | NoteDeadRegion(regionHandle); | ||
520 | m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); | ||
521 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
522 | return false; | ||
523 | } | ||
524 | catch (Exception e) | ||
525 | { | ||
526 | NoteDeadRegion(regionHandle); | ||
527 | m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); | ||
528 | m_log.DebugFormat("[HGrid]: {0}", e); | ||
529 | return false; | ||
530 | } | ||
531 | } | ||
532 | else | ||
533 | { | ||
534 | return false; | ||
535 | } | ||
536 | } | ||
537 | |||
538 | /// <summary> | ||
539 | /// | ||
540 | /// </summary> | ||
541 | /// <param name="regionHandle"></param> | ||
542 | /// <param name="agentID"></param> | ||
543 | /// <param name="position"></param> | ||
544 | /// <returns></returns> | ||
545 | public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) | ||
546 | { | ||
547 | |||
548 | RegionInfo[] regions = m_regionsOnInstance.ToArray(); | ||
549 | bool banned = false; | ||
550 | bool localregion = false; | ||
551 | |||
552 | for (int i = 0; i < regions.Length; i++) | ||
553 | { | ||
554 | if (regions[i] != null) | ||
555 | { | ||
556 | if (regions[i].RegionHandle == regionHandle) | ||
557 | { | ||
558 | localregion = true; | ||
559 | if (regions[i].EstateSettings.IsBanned(agentID)) | ||
560 | { | ||
561 | banned = true; | ||
562 | break; | ||
563 | } | ||
564 | } | ||
565 | } | ||
566 | } | ||
567 | |||
568 | if (banned) | ||
569 | return false; | ||
570 | if (localregion) | ||
571 | return m_localBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); | ||
572 | |||
573 | return base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); | ||
574 | |||
575 | } | ||
576 | |||
577 | public override bool ExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) | ||
578 | { | ||
579 | RegionInfo regInfo = null; | ||
580 | try | ||
581 | { | ||
582 | if (m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical)) | ||
583 | { | ||
584 | return true; | ||
585 | } | ||
586 | |||
587 | regInfo = RequestNeighbourInfo(regionHandle); | ||
588 | if (regInfo != null) | ||
589 | { | ||
590 | bool retValue = false; | ||
591 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
592 | typeof(OGS1InterRegionRemoting), | ||
593 | "tcp://" + regInfo.RemotingAddress + | ||
594 | ":" + regInfo.RemotingPort + | ||
595 | "/InterRegions"); | ||
596 | |||
597 | if (remObject != null) | ||
598 | { | ||
599 | retValue = | ||
600 | remObject.ExpectAvatarCrossing(regionHandle, agentID.Guid, new sLLVector3(position), | ||
601 | isPhysical); | ||
602 | } | ||
603 | else | ||
604 | { | ||
605 | m_log.Warn("[HGrid]: Remoting object not found"); | ||
606 | } | ||
607 | remObject = null; | ||
608 | |||
609 | return retValue; | ||
610 | } | ||
611 | //TODO need to see if we know about where this region is and use .net remoting | ||
612 | // to inform it. | ||
613 | NoteDeadRegion(regionHandle); | ||
614 | return false; | ||
615 | } | ||
616 | catch (RemotingException e) | ||
617 | { | ||
618 | NoteDeadRegion(regionHandle); | ||
619 | m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); | ||
620 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
621 | return false; | ||
622 | } | ||
623 | catch (SocketException e) | ||
624 | { | ||
625 | NoteDeadRegion(regionHandle); | ||
626 | m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region: " + regionHandle); | ||
627 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
628 | return false; | ||
629 | } | ||
630 | catch (InvalidCredentialException e) | ||
631 | { | ||
632 | NoteDeadRegion(regionHandle); | ||
633 | m_log.Warn("[HGrid]: Invalid Credential Exception: Invalid Credentials : " + regionHandle); | ||
634 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
635 | return false; | ||
636 | } | ||
637 | catch (AuthenticationException e) | ||
638 | { | ||
639 | NoteDeadRegion(regionHandle); | ||
640 | m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region: " + regionHandle); | ||
641 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
642 | return false; | ||
643 | } | ||
644 | catch (Exception e) | ||
645 | { | ||
646 | NoteDeadRegion(regionHandle); | ||
647 | m_log.Warn("[HGrid]: Unknown exception: Unable to connect to adjacent region: " + regionHandle); | ||
648 | m_log.DebugFormat("[HGrid]: {0}", e); | ||
649 | return false; | ||
650 | } | ||
651 | } | ||
652 | |||
653 | public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) | ||
654 | { | ||
655 | m_log.Debug("[HGrid]: TellRegion " + regionHandle + " ToCloseChildConnection for " + agentID); | ||
656 | RegionInfo regInfo = null; | ||
657 | try | ||
658 | { | ||
659 | if (m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID)) | ||
660 | { | ||
661 | return true; | ||
662 | } | ||
663 | |||
664 | regInfo = RequestNeighbourInfo(regionHandle); | ||
665 | if (regInfo != null) | ||
666 | { | ||
667 | // bool retValue = false; | ||
668 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
669 | typeof(OGS1InterRegionRemoting), | ||
670 | "tcp://" + regInfo.RemotingAddress + | ||
671 | ":" + regInfo.RemotingPort + | ||
672 | "/InterRegions"); | ||
673 | |||
674 | if (remObject != null) | ||
675 | { | ||
676 | // retValue = | ||
677 | remObject.TellRegionToCloseChildConnection(regionHandle, agentID.Guid); | ||
678 | } | ||
679 | else | ||
680 | { | ||
681 | m_log.Warn("[HGrid]: Remoting object not found"); | ||
682 | } | ||
683 | remObject = null; | ||
684 | |||
685 | return true; | ||
686 | } | ||
687 | //TODO need to see if we know about where this region is and use .net remoting | ||
688 | // to inform it. | ||
689 | NoteDeadRegion(regionHandle); | ||
690 | return false; | ||
691 | } | ||
692 | catch (RemotingException) | ||
693 | { | ||
694 | NoteDeadRegion(regionHandle); | ||
695 | m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region to tell it to close child agents: " + regInfo.RegionName + | ||
696 | " " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
697 | //m_log.Debug(e.ToString()); | ||
698 | return false; | ||
699 | } | ||
700 | catch (SocketException e) | ||
701 | { | ||
702 | NoteDeadRegion(regionHandle); | ||
703 | m_log.Warn("[HGridS]: Socket Error: Unable to connect to adjacent region using tcp://" + | ||
704 | regInfo.RemotingAddress + | ||
705 | ":" + regInfo.RemotingPort + | ||
706 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + | ||
707 | " - Is this neighbor up?"); | ||
708 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
709 | return false; | ||
710 | } | ||
711 | catch (InvalidCredentialException e) | ||
712 | { | ||
713 | NoteDeadRegion(regionHandle); | ||
714 | m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + | ||
715 | regInfo.RemotingAddress + | ||
716 | ":" + regInfo.RemotingPort + | ||
717 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
718 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
719 | return false; | ||
720 | } | ||
721 | catch (AuthenticationException e) | ||
722 | { | ||
723 | NoteDeadRegion(regionHandle); | ||
724 | m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" + | ||
725 | regInfo.RemotingAddress + | ||
726 | ":" + regInfo.RemotingPort + | ||
727 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
728 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
729 | return false; | ||
730 | } | ||
731 | catch (WebException e) | ||
732 | { | ||
733 | NoteDeadRegion(regionHandle); | ||
734 | m_log.Warn("[HGrid]: WebException exception: Unable to connect to adjacent region using tcp://" + | ||
735 | regInfo.RemotingAddress + | ||
736 | ":" + regInfo.RemotingPort + | ||
737 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
738 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
739 | return false; | ||
740 | } | ||
741 | catch (Exception e) | ||
742 | { | ||
743 | NoteDeadRegion(regionHandle); | ||
744 | // This line errors with a Null Reference Exception.. Why? @.@ | ||
745 | //m_log.Warn("Unknown exception: Unable to connect to adjacent region using tcp://" + regInfo.RemotingAddress + | ||
746 | // ":" + regInfo.RemotingPort + | ||
747 | //"/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + " - This is likely caused by an incompatibility in the protocol between this sim and that one"); | ||
748 | m_log.DebugFormat("[HGrid]: {0}", e); | ||
749 | return false; | ||
750 | } | ||
751 | } | ||
752 | |||
753 | public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) | ||
754 | { | ||
755 | return m_localBackend.AcknowledgeAgentCrossed(regionHandle, agentId); | ||
756 | } | ||
757 | |||
758 | public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primId) | ||
759 | { | ||
760 | return m_localBackend.AcknowledgePrimCrossed(regionHandle, primId); | ||
761 | } | ||
762 | |||
763 | #endregion | ||
764 | |||
765 | #region Methods triggered by calls from external instances | ||
766 | |||
767 | /// <summary> | ||
768 | /// | ||
769 | /// </summary> | ||
770 | /// <param name="regionHandle"></param> | ||
771 | /// <param name="agentData"></param> | ||
772 | /// <returns></returns> | ||
773 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
774 | { | ||
775 | AdjustUserInformation(agentData); | ||
776 | |||
777 | m_log.Info("[HGrid]: " + gdebugRegionName + ": Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); | ||
778 | |||
779 | return m_localBackend.IncomingChildAgent(regionHandle, agentData); | ||
780 | } | ||
781 | |||
782 | public bool TriggerRegionUp(RegionUpData regionData, ulong regionhandle) | ||
783 | { | ||
784 | m_log.Info( | ||
785 | "[HGrid]: " + | ||
786 | m_localBackend._gdebugRegionName + "Incoming HGrid RegionUpReport: " + "(" + regionData.X + | ||
787 | "," + regionData.Y + "). Giving this region a fresh set of 'dead' tries"); | ||
788 | |||
789 | RegionInfo nRegionInfo = new RegionInfo(); | ||
790 | nRegionInfo.SetEndPoint("127.0.0.1", regionData.PORT); | ||
791 | nRegionInfo.ExternalHostName = regionData.IPADDR; | ||
792 | nRegionInfo.RegionLocX = regionData.X; | ||
793 | nRegionInfo.RegionLocY = regionData.Y; | ||
794 | |||
795 | lock (m_deadRegionCache) | ||
796 | { | ||
797 | if (m_deadRegionCache.ContainsKey(nRegionInfo.RegionHandle)) | ||
798 | { | ||
799 | m_deadRegionCache.Remove(nRegionInfo.RegionHandle); | ||
800 | } | ||
801 | } | ||
802 | |||
803 | return m_localBackend.TriggerRegionUp(nRegionInfo, regionhandle); | ||
804 | } | ||
805 | |||
806 | public bool TriggerChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) | ||
807 | { | ||
808 | //m_log.Info("[INTER]: Incoming HGrid Child Agent Data Update"); | ||
809 | |||
810 | return m_localBackend.TriggerChildAgentUpdate(regionHandle, cAgentData); | ||
811 | } | ||
812 | |||
813 | /// <summary> | ||
814 | /// | ||
815 | /// </summary> | ||
816 | /// <param name="regionHandle"></param> | ||
817 | /// <param name="agentData"></param> | ||
818 | /// <returns></returns> | ||
819 | public bool IncomingPrim(ulong regionHandle, UUID primID, string objData, int XMLMethod) | ||
820 | { | ||
821 | m_log.Debug("[HGrid]: Incoming Prim"); | ||
822 | m_localBackend.TriggerExpectPrim(regionHandle, primID, objData, XMLMethod); | ||
823 | |||
824 | return true; | ||
825 | } | ||
826 | |||
827 | /// <summary> | ||
828 | /// | ||
829 | /// </summary> | ||
830 | /// <param name="regionHandle"></param> | ||
831 | /// <param name="agentID"></param> | ||
832 | /// <param name="position"></param> | ||
833 | /// <returns></returns> | ||
834 | public bool TriggerExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) | ||
835 | { | ||
836 | return m_localBackend.TriggerExpectAvatarCrossing(regionHandle, agentID, position, isFlying); | ||
837 | } | ||
838 | |||
839 | public bool TriggerExpectPrimCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isPhysical) | ||
840 | { | ||
841 | return m_localBackend.TriggerExpectPrimCrossing(regionHandle, agentID, position, isPhysical); | ||
842 | } | ||
843 | |||
844 | public bool TriggerTellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) | ||
845 | { | ||
846 | return m_localBackend.TriggerTellRegionToCloseChildConnection(regionHandle, agentID); | ||
847 | } | ||
848 | |||
849 | int timeOut = 10; //10 seconds | ||
850 | /// <summary> | ||
851 | /// Check that a region is available for TCP comms. This is necessary for .NET remoting between regions. | ||
852 | /// </summary> | ||
853 | /// <param name="address"></param> | ||
854 | /// <param name="port"></param> | ||
855 | /// <param name="retry"></param> | ||
856 | /// <returns></returns> | ||
857 | public bool CheckRegion(string address, uint port, bool retry) | ||
858 | { | ||
859 | bool available = false; | ||
860 | bool timed_out = true; | ||
861 | |||
862 | IPAddress ia; | ||
863 | IPAddress.TryParse(address, out ia); | ||
864 | IPEndPoint m_EndPoint = new IPEndPoint(ia, (int)port); | ||
865 | |||
866 | AsyncCallback callback = delegate(IAsyncResult iar) | ||
867 | { | ||
868 | Socket s = (Socket)iar.AsyncState; | ||
869 | try | ||
870 | { | ||
871 | s.EndConnect(iar); | ||
872 | available = true; | ||
873 | timed_out = false; | ||
874 | } | ||
875 | catch (Exception e) | ||
876 | { | ||
877 | m_log.DebugFormat( | ||
878 | "[HGrid]: Callback EndConnect exception: {0}:{1}", e.Message, e.StackTrace); | ||
879 | } | ||
880 | |||
881 | s.Close(); | ||
882 | }; | ||
883 | |||
884 | try | ||
885 | { | ||
886 | Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); | ||
887 | IAsyncResult ar = socket.BeginConnect(m_EndPoint, callback, socket); | ||
888 | ar.AsyncWaitHandle.WaitOne(timeOut * 1000, false); | ||
889 | } | ||
890 | catch (Exception e) | ||
891 | { | ||
892 | m_log.DebugFormat( | ||
893 | "[HGrid]: CheckRegion Socket Setup exception: {0}:{1}", e.Message, e.StackTrace); | ||
894 | |||
895 | return false; | ||
896 | } | ||
897 | |||
898 | if (timed_out) | ||
899 | { | ||
900 | m_log.DebugFormat( | ||
901 | "[HGrid]: socket [{0}] timed out ({1}) waiting to obtain a connection.", | ||
902 | m_EndPoint, timeOut * 1000); | ||
903 | |||
904 | if (retry) | ||
905 | { | ||
906 | return CheckRegion(address, port, false); | ||
907 | } | ||
908 | } | ||
909 | |||
910 | return available; | ||
911 | } | ||
912 | |||
913 | public override bool CheckRegion(string address, uint port) | ||
914 | { | ||
915 | return CheckRegion(address, port, true); | ||
916 | } | ||
917 | |||
918 | public void NoteDeadRegion(ulong regionhandle) | ||
919 | { | ||
920 | lock (m_deadRegionCache) | ||
921 | { | ||
922 | if (m_deadRegionCache.ContainsKey(regionhandle)) | ||
923 | { | ||
924 | m_deadRegionCache[regionhandle] = m_deadRegionCache[regionhandle] + 1; | ||
925 | } | ||
926 | else | ||
927 | { | ||
928 | m_deadRegionCache.Add(regionhandle, 1); | ||
929 | } | ||
930 | } | ||
931 | |||
932 | } | ||
933 | |||
934 | #endregion | ||
935 | |||
936 | |||
937 | } | 258 | } |
938 | } | 259 | } |