diff options
Diffstat (limited to '')
5 files changed, 2 insertions, 1133 deletions
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs index c8a540b..8b7c3d1 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsGridMode.cs | |||
@@ -56,7 +56,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
56 | // From constructor at CommunicationsOGS1 | 56 | // From constructor at CommunicationsOGS1 |
57 | HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, httpServer, assetCache, sman, m_userProfileCacheService); | 57 | HGGridServices gridInterComms = new HGGridServicesGridMode(serversInfo, httpServer, assetCache, sman, m_userProfileCacheService); |
58 | m_gridService = gridInterComms; | 58 | m_gridService = gridInterComms; |
59 | m_interRegion = gridInterComms; | ||
60 | m_osw = gridInterComms; | 59 | m_osw = gridInterComms; |
61 | 60 | ||
62 | // The HG InventoryService always uses secure handlers | 61 | // The HG InventoryService always uses secure handlers |
diff --git a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs index 5feea4d..21e651d 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGCommunicationsStandalone.cs | |||
@@ -44,9 +44,8 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
44 | IUserService userService, | 44 | IUserService userService, |
45 | IUserAdminService userServiceAdmin, | 45 | IUserAdminService userServiceAdmin, |
46 | LocalInventoryService inventoryService, | 46 | LocalInventoryService inventoryService, |
47 | IInterRegionCommunications interRegionService, | ||
48 | HGGridServices gridService, IMessagingService messageService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) | 47 | HGGridServices gridService, IMessagingService messageService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile) |
49 | : base(serversInfo, httpServer, assetCache, userService, userServiceAdmin, inventoryService, interRegionService, gridService, messageService, libraryRootFolder, dumpAssetsToFile) | 48 | : base(serversInfo, httpServer, assetCache, userService, userServiceAdmin, inventoryService, gridService, messageService, libraryRootFolder, dumpAssetsToFile) |
50 | { | 49 | { |
51 | gridService.UserProfileCache = m_userProfileCacheService; | 50 | gridService.UserProfileCache = m_userProfileCacheService; |
52 | m_assetCache = assetCache; | 51 | m_assetCache = assetCache; |
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs index 24db63e..08d74f3 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServices.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
55 | /// hyperlinks, as well as processing all the inter-region comms between a region and | 55 | /// hyperlinks, as well as processing all the inter-region comms between a region and |
56 | /// an hyperlinked region. | 56 | /// an hyperlinked region. |
57 | /// </summary> | 57 | /// </summary> |
58 | public class HGGridServices : IGridServices, IInterRegionCommunications, IHyperlink | 58 | public class HGGridServices : IGridServices, IHyperlink |
59 | { | 59 | { |
60 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 60 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
61 | 61 | ||
@@ -777,80 +777,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
777 | return resp; | 777 | return resp; |
778 | } | 778 | } |
779 | 779 | ||
780 | #region IInterRegionCommunications interface | ||
781 | |||
782 | public virtual bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) { return false; } | ||
783 | public virtual bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID) { return false; } | ||
784 | public virtual bool CheckRegion(string address, uint port) { return false; } | ||
785 | public virtual bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) { return false; } | ||
786 | |||
787 | public virtual bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) { | ||
788 | // Remote region | ||
789 | RegionInfo regInfo = null; | ||
790 | ulong remoteHandle = 0; | ||
791 | try | ||
792 | { | ||
793 | regInfo = RequestNeighbourInfo(regionHandle); | ||
794 | if (regInfo != null) | ||
795 | { | ||
796 | try | ||
797 | { | ||
798 | remoteHandle = Convert.ToUInt64(regInfo.regionSecret); | ||
799 | } | ||
800 | catch | ||
801 | { | ||
802 | m_log.Warn("[HGrid]: Invalid remote region with handle " + regInfo.regionSecret); | ||
803 | return false; | ||
804 | } | ||
805 | //Console.WriteLine("XXX---- Sending Expectavatarcrossing into : " + remoteHandle); | ||
806 | |||
807 | bool retValue = false; | ||
808 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
809 | typeof(OGS1InterRegionRemoting), | ||
810 | "tcp://" + regInfo.RemotingAddress + | ||
811 | ":" + regInfo.RemotingPort + | ||
812 | "/InterRegions"); | ||
813 | |||
814 | if (remObject != null) | ||
815 | { | ||
816 | retValue = | ||
817 | remObject.ExpectAvatarCrossing(remoteHandle, agentID.Guid, new sLLVector3(position), | ||
818 | isFlying); | ||
819 | } | ||
820 | else | ||
821 | { | ||
822 | m_log.Warn("[HGrid]: Remoting object not found"); | ||
823 | } | ||
824 | remObject = null; | ||
825 | |||
826 | return retValue; | ||
827 | } | ||
828 | //TODO need to see if we know about where this region is and use .net remoting | ||
829 | // to inform it. | ||
830 | //NoteDeadRegion(regionHandle); | ||
831 | return false; | ||
832 | } | ||
833 | catch (RemotingException e) | ||
834 | { | ||
835 | // NoteDeadRegion(regionHandle); | ||
836 | |||
837 | m_log.WarnFormat( | ||
838 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
839 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
840 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
841 | |||
842 | return false; | ||
843 | } | ||
844 | catch | ||
845 | { | ||
846 | // NoteDeadRegion(regionHandle); | ||
847 | return false; | ||
848 | } | ||
849 | |||
850 | } | ||
851 | |||
852 | public virtual bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying) { return false; } | ||
853 | |||
854 | public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData) | 780 | public bool SendUserInformation(RegionInfo regInfo, AgentCircuitData agentData) |
855 | { | 781 | { |
856 | CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); | 782 | CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); |
@@ -887,260 +813,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
887 | return true; | 813 | return true; |
888 | } | 814 | } |
889 | 815 | ||
890 | public virtual bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
891 | { | ||
892 | // If we're here, it's because regionHandle is a remote, non-grided region | ||
893 | m_log.Info("[HGrid]: InformRegionOfChildAgent for " + regionHandle); | ||
894 | |||
895 | RegionInfo regInfo = GetHyperlinkRegion(regionHandle); | ||
896 | if (regInfo == null) | ||
897 | return false; | ||
898 | |||
899 | //ulong realHandle = regionHandle; | ||
900 | |||
901 | if (!SendUserInformation(regInfo, agentData)) | ||
902 | { | ||
903 | m_log.Warn("[HGrid]: Failed to inform remote region of user."); | ||
904 | //return false; | ||
905 | } | ||
906 | |||
907 | try | ||
908 | { | ||
909 | // ... and then | ||
910 | |||
911 | m_log.Debug("[HGrid]: Region is hyperlink."); | ||
912 | bool retValue = false; | ||
913 | try | ||
914 | { | ||
915 | regionHandle = Convert.ToUInt64(regInfo.regionSecret); | ||
916 | } | ||
917 | catch (Exception) | ||
918 | { | ||
919 | m_log.Warn("[HGrid]: Invalid hyperlink region."); | ||
920 | return false; | ||
921 | } | ||
922 | |||
923 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
924 | typeof(OGS1InterRegionRemoting), | ||
925 | "tcp://" + regInfo.RemotingAddress + | ||
926 | ":" + regInfo.RemotingPort + | ||
927 | "/InterRegions"); | ||
928 | |||
929 | if (remObject != null) | ||
930 | { | ||
931 | sAgentCircuitData sag = new sAgentCircuitData(agentData); | ||
932 | //CachedUserInfo uinfo = m_userProfileCache.GetUserDetails(agentData.AgentID); | ||
933 | |||
934 | //// May need to change agent's name | ||
935 | //if (IsLocalUser(uinfo)) | ||
936 | //{ | ||
937 | // sag.firstname = agentData.firstname + "." + agentData.lastname; | ||
938 | // sag.lastname = serversInfo.UserURL; //HGNetworkServersInfo.Singleton.LocalUserServerURI; | ||
939 | //} | ||
940 | retValue = remObject.InformRegionOfChildAgent(regionHandle, sag); | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | m_log.Warn("[HGrid]: remoting object not found"); | ||
945 | } | ||
946 | remObject = null; | ||
947 | m_log.Info("[HGrid]: tried to InformRegionOfChildAgent for " + | ||
948 | agentData.firstname + " " + agentData.lastname + " and got " + | ||
949 | retValue.ToString()); | ||
950 | |||
951 | // Remove the info from this region | ||
952 | //if (m_knownRegions.ContainsKey(uinfo.UserProfile.ID)) | ||
953 | // m_knownRegions.Remove(uinfo.UserProfile.ID); | ||
954 | |||
955 | return retValue; | ||
956 | } | ||
957 | catch (RemotingException e) | ||
958 | { | ||
959 | //NoteDeadRegion(regionHandle); | ||
960 | |||
961 | m_log.WarnFormat( | ||
962 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
963 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
964 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
965 | |||
966 | return false; | ||
967 | } | ||
968 | catch (SocketException e) | ||
969 | { | ||
970 | //NoteDeadRegion(regionHandle); | ||
971 | |||
972 | m_log.WarnFormat( | ||
973 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
974 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
975 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
976 | |||
977 | return false; | ||
978 | } | ||
979 | catch (InvalidCredentialException e) | ||
980 | { | ||
981 | //NoteDeadRegion(regionHandle); | ||
982 | |||
983 | m_log.WarnFormat( | ||
984 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
985 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
986 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
987 | |||
988 | return false; | ||
989 | } | ||
990 | catch (AuthenticationException e) | ||
991 | { | ||
992 | //NoteDeadRegion(regionHandle); | ||
993 | |||
994 | m_log.WarnFormat( | ||
995 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
996 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
997 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
998 | |||
999 | return false; | ||
1000 | } | ||
1001 | catch (Exception e) | ||
1002 | { | ||
1003 | //NoteDeadRegion(regionHandle); | ||
1004 | |||
1005 | if (regInfo != null) | ||
1006 | { | ||
1007 | m_log.WarnFormat( | ||
1008 | "[HGrid]: Remoting Error: Unable to connect to adjacent region: {0} {1},{2}", | ||
1009 | regInfo.RegionName, regInfo.RegionLocX, regInfo.RegionLocY); | ||
1010 | } | ||
1011 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
1012 | |||
1013 | return false; | ||
1014 | } | ||
1015 | |||
1016 | |||
1017 | } | ||
1018 | |||
1019 | public virtual bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) { return false; } | ||
1020 | |||
1021 | public virtual bool RegionUp(SerializableRegionInfo region, ulong regionhandle) { | ||
1022 | |||
1023 | ulong realHandle = FindRegionHandle(regionhandle); | ||
1024 | |||
1025 | if (realHandle == regionhandle) // something wrong, not remote region | ||
1026 | return false; | ||
1027 | |||
1028 | SerializableRegionInfo regInfo = null; | ||
1029 | try | ||
1030 | { | ||
1031 | // You may ask why this is in here... | ||
1032 | // The region asking the grid services about itself.. | ||
1033 | // And, surprisingly, the reason is.. it doesn't know | ||
1034 | // it's own remoting port! How special. | ||
1035 | RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); | ||
1036 | |||
1037 | region = new SerializableRegionInfo(RequestNeighbourInfo(realHandle)); | ||
1038 | region.RemotingAddress = region.ExternalHostName; | ||
1039 | region.RemotingPort = NetworkServersInfo.RemotingListenerPort; | ||
1040 | region.HttpPort = serversInfo.HttpListenerPort; | ||
1041 | |||
1042 | regInfo = new SerializableRegionInfo(RequestNeighbourInfo(regionhandle)); | ||
1043 | if (regInfo != null) | ||
1044 | { | ||
1045 | // If we're not trying to remote to ourselves. | ||
1046 | if (regInfo.RemotingAddress != region.RemotingAddress && region.RemotingAddress != null) | ||
1047 | { | ||
1048 | //don't want to be creating a new link to the remote instance every time like we are here | ||
1049 | bool retValue = false; | ||
1050 | |||
1051 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
1052 | typeof(OGS1InterRegionRemoting), | ||
1053 | "tcp://" + | ||
1054 | regInfo.RemotingAddress + | ||
1055 | ":" + regInfo.RemotingPort + | ||
1056 | "/InterRegions"); | ||
1057 | |||
1058 | if (remObject != null) | ||
1059 | { | ||
1060 | retValue = remObject.RegionUp(regiondata, realHandle); | ||
1061 | } | ||
1062 | else | ||
1063 | { | ||
1064 | m_log.Warn("[HGrid]: remoting object not found"); | ||
1065 | } | ||
1066 | remObject = null; | ||
1067 | |||
1068 | m_log.Info( | ||
1069 | "[HGrid]: tried to inform region I'm up"); | ||
1070 | |||
1071 | return retValue; | ||
1072 | } | ||
1073 | else | ||
1074 | { | ||
1075 | // We're trying to inform ourselves via remoting. | ||
1076 | // This is here because we're looping over the listeners before we get here. | ||
1077 | // Odd but it should work. | ||
1078 | return true; | ||
1079 | } | ||
1080 | } | ||
1081 | |||
1082 | return false; | ||
1083 | } | ||
1084 | catch (RemotingException e) | ||
1085 | { | ||
1086 | m_log.Warn("[HGrid]: Remoting Error: Unable to connect to adjacent region using tcp://" + | ||
1087 | regInfo.RemotingAddress + | ||
1088 | ":" + regInfo.RemotingPort + | ||
1089 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + | ||
1090 | " - Is this neighbor up?"); | ||
1091 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
1092 | return false; | ||
1093 | } | ||
1094 | catch (SocketException e) | ||
1095 | { | ||
1096 | m_log.Warn("[HGrid]: Socket Error: Unable to connect to adjacent region using tcp://" + | ||
1097 | regInfo.RemotingAddress + | ||
1098 | ":" + regInfo.RemotingPort + | ||
1099 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY + | ||
1100 | " - Is this neighbor up?"); | ||
1101 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
1102 | return false; | ||
1103 | } | ||
1104 | catch (InvalidCredentialException e) | ||
1105 | { | ||
1106 | m_log.Warn("[HGrid]: Invalid Credentials: Unable to connect to adjacent region using tcp://" + | ||
1107 | regInfo.RemotingAddress + | ||
1108 | ":" + regInfo.RemotingPort + | ||
1109 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
1110 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
1111 | return false; | ||
1112 | } | ||
1113 | catch (AuthenticationException e) | ||
1114 | { | ||
1115 | m_log.Warn("[HGrid]: Authentication exception: Unable to connect to adjacent region using tcp://" + | ||
1116 | regInfo.RemotingAddress + | ||
1117 | ":" + regInfo.RemotingPort + | ||
1118 | "/InterRegions - @ " + regInfo.RegionLocX + "," + regInfo.RegionLocY); | ||
1119 | m_log.DebugFormat("[HGrid]: {0} {1}", e.Source, e.Message); | ||
1120 | return false; | ||
1121 | } | ||
1122 | catch (Exception e) | ||
1123 | { | ||
1124 | m_log.Debug(e.ToString()); | ||
1125 | return false; | ||
1126 | } | ||
1127 | |||
1128 | } | ||
1129 | |||
1130 | public virtual bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) { return false; } | ||
1131 | |||
1132 | public virtual List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online) | ||
1133 | { | ||
1134 | return new List<UUID>(); | ||
1135 | } | ||
1136 | |||
1137 | public virtual bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) | ||
1138 | { | ||
1139 | return true; | ||
1140 | } | ||
1141 | |||
1142 | |||
1143 | #endregion | ||
1144 | 816 | ||
1145 | #region Methods triggered by calls from external instances | 817 | #region Methods triggered by calls from external instances |
1146 | 818 | ||
diff --git a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs index 94646d2..85fb4b7 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGGridServicesGridMode.cs | |||
@@ -71,9 +71,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
71 | : base(servers_info, httpServe, asscache, sman) | 71 | : base(servers_info, httpServe, asscache, sman) |
72 | { | 72 | { |
73 | m_remoteBackend = new OGS1GridServices(servers_info, httpServe); | 73 | m_remoteBackend = new OGS1GridServices(servers_info, httpServe); |
74 | // Let's deregister this, so we can handle it here first | ||
75 | InterRegionSingleton.Instance.OnChildAgent -= m_remoteBackend.IncomingChildAgent; | ||
76 | InterRegionSingleton.Instance.OnChildAgent += IncomingChildAgent; | ||
77 | m_userProfileCache = userv; | 74 | m_userProfileCache = userv; |
78 | } | 75 | } |
79 | 76 | ||
@@ -158,125 +155,6 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
158 | 155 | ||
159 | #endregion | 156 | #endregion |
160 | 157 | ||
161 | #region IInterRegionCommunications interface | ||
162 | |||
163 | public override bool AcknowledgeAgentCrossed(ulong regionHandle, UUID agentId) | ||
164 | { | ||
165 | return m_remoteBackend.AcknowledgeAgentCrossed(regionHandle, agentId); | ||
166 | } | ||
167 | |||
168 | public override bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID) | ||
169 | { | ||
170 | return m_remoteBackend.AcknowledgePrimCrossed(regionHandle, primID); | ||
171 | } | ||
172 | |||
173 | public override bool CheckRegion(string address, uint port) | ||
174 | { | ||
175 | return m_remoteBackend.CheckRegion(address, port); | ||
176 | } | ||
177 | |||
178 | public override bool ChildAgentUpdate(ulong regionHandle, ChildAgentDataUpdate cAgentData) | ||
179 | { | ||
180 | return m_remoteBackend.ChildAgentUpdate(regionHandle, cAgentData); | ||
181 | } | ||
182 | |||
183 | public override bool ExpectAvatarCrossing(ulong regionHandle, UUID agentID, Vector3 position, bool isFlying) | ||
184 | { | ||
185 | if (base.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying)) | ||
186 | return true; | ||
187 | return m_remoteBackend.ExpectAvatarCrossing(regionHandle, agentID, position, isFlying); | ||
188 | } | ||
189 | |||
190 | public override bool ExpectPrimCrossing(ulong regionHandle, UUID primID, Vector3 position, bool isFlying) | ||
191 | { | ||
192 | return m_remoteBackend.ExpectPrimCrossing(regionHandle, primID, position, isFlying); | ||
193 | } | ||
194 | |||
195 | public override bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
196 | { | ||
197 | CachedUserInfo user = m_userProfileCache.GetUserDetails(agentData.AgentID); | ||
198 | |||
199 | if (IsLocalUser(user)) | ||
200 | { | ||
201 | Console.WriteLine("XXX Home User XXX"); | ||
202 | if (IsHyperlinkRegion(regionHandle)) | ||
203 | { | ||
204 | Console.WriteLine("XXX Going Hyperlink XXX"); | ||
205 | return base.InformRegionOfChildAgent(regionHandle, agentData); | ||
206 | } | ||
207 | else | ||
208 | { | ||
209 | // non-hypergrid case | ||
210 | Console.WriteLine("XXX Going local-grid region XXX"); | ||
211 | return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData); | ||
212 | } | ||
213 | } | ||
214 | |||
215 | // Foregin users | ||
216 | Console.WriteLine("XXX Foreign User XXX"); | ||
217 | if (IsLocalRegion(regionHandle)) // regions on the same instance | ||
218 | { | ||
219 | Console.WriteLine("XXX Going onInstance region XXX"); | ||
220 | return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData); | ||
221 | } | ||
222 | |||
223 | if (IsHyperlinkRegion(regionHandle)) // hyperlinked regions | ||
224 | { | ||
225 | Console.WriteLine("XXX Going Hyperlink XXX"); | ||
226 | return base.InformRegionOfChildAgent(regionHandle, agentData); | ||
227 | } | ||
228 | else | ||
229 | { | ||
230 | // foreign user going to a non-local region on the same grid | ||
231 | // We need to inform that region about this user before | ||
232 | // proceeding to the normal backend process. | ||
233 | Console.WriteLine("XXX Going local-grid region XXX"); | ||
234 | RegionInfo regInfo = RequestNeighbourInfo(regionHandle); | ||
235 | if (regInfo != null) | ||
236 | // For now, don't test if this succeeds/fails; until someone complains, this is a feature :-) | ||
237 | InformRegionOfUser(regInfo, agentData); | ||
238 | return m_remoteBackend.InformRegionOfChildAgent(regionHandle, agentData); | ||
239 | } | ||
240 | |||
241 | } | ||
242 | |||
243 | public override bool InformRegionOfPrimCrossing(ulong regionHandle, UUID primID, string objData, int XMLMethod) | ||
244 | { | ||
245 | return m_remoteBackend.InformRegionOfPrimCrossing(regionHandle, primID, objData, XMLMethod); | ||
246 | } | ||
247 | |||
248 | public override bool RegionUp(SerializableRegionInfo region, ulong regionhandle) | ||
249 | { | ||
250 | if (m_remoteBackend.RegionUp(region, regionhandle)) | ||
251 | return true; | ||
252 | return base.RegionUp(region, regionhandle); | ||
253 | } | ||
254 | |||
255 | public override bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID) | ||
256 | { | ||
257 | return m_remoteBackend.TellRegionToCloseChildConnection(regionHandle, agentID); | ||
258 | } | ||
259 | |||
260 | |||
261 | #endregion | ||
262 | |||
263 | #region Methods triggered by calls from external instances | ||
264 | |||
265 | /// <summary> | ||
266 | /// | ||
267 | /// </summary> | ||
268 | /// <param name="regionHandle"></param> | ||
269 | /// <param name="agentData"></param> | ||
270 | /// <returns></returns> | ||
271 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
272 | { | ||
273 | AdjustUserInformation(agentData); | ||
274 | |||
275 | m_log.Info("[HGrid]: Incoming HGrid Agent " + agentData.firstname + " " + agentData.lastname); | ||
276 | |||
277 | return m_remoteBackend.IncomingChildAgent(regionHandle, agentData); | ||
278 | } | ||
279 | #endregion | ||
280 | 158 | ||
281 | } | 159 | } |
282 | } | 160 | } |
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 | } |