aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs96
1 files changed, 94 insertions, 2 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index f23f4e0..d91e10d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -34,6 +34,7 @@ using Nini.Config;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications;
37using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
@@ -105,6 +106,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
105 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>(); 106 private Dictionary<ulong, Scene> m_scenes = new Dictionary<ulong,Scene>();
106 private IMessageTransferModule m_TransferModule = null; 107 private IMessageTransferModule m_TransferModule = null;
107 108
109 private IGridServices m_gridServices = null;
110
108 #region IRegionModule Members 111 #region IRegionModule Members
109 112
110 public void Initialise(Scene scene, IConfigSource config) 113 public void Initialise(Scene scene, IConfigSource config)
@@ -137,6 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
137 if (m_scenes.Count > 0) 140 if (m_scenes.Count > 0)
138 { 141 {
139 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>(); 142 m_TransferModule = m_initialScene.RequestModuleInterface<IMessageTransferModule>();
143 m_gridServices = m_initialScene.CommsManager.GridService;
140 } 144 }
141 if (m_TransferModule == null) 145 if (m_TransferModule == null)
142 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); 146 m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work");
@@ -158,6 +162,89 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
158 162
159 #endregion 163 #endregion
160 164
165 #region IInterregionFriendsComms
166
167 public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online)
168 {
169 List<UUID> tpdAway = new List<UUID>();
170
171 // destRegionHandle is a region on another server
172 RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle);
173 if (info != null)
174 {
175 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk";
176
177 Hashtable reqParams = new Hashtable();
178 reqParams["agentID"] = agentId.ToString();
179 reqParams["agentOnline"] = online;
180 int count = 0;
181 foreach (UUID uuid in friends)
182 {
183 reqParams["friendID_" + count++] = uuid.ToString();
184 }
185 reqParams["friendCount"] = count;
186
187 IList parameters = new ArrayList();
188 parameters.Add(reqParams);
189 try
190 {
191 XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters);
192 XmlRpcResponse response = request.Send(httpServer, 5000);
193 Hashtable respData = (Hashtable)response.Value;
194
195 count = (int)respData["friendCount"];
196 for (int i = 0; i < count; ++i)
197 {
198 UUID uuid;
199 if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid);
200 }
201 }
202 catch (Exception e)
203 {
204 m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e);
205 }
206 }
207 else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle);
208
209 return tpdAway;
210 }
211
212 public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID)
213 {
214 // destRegionHandle is a region on another server
215 RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle);
216 if (info == null)
217 {
218 m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle);
219 return false; // region not found???
220 }
221
222 string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk";
223
224 Hashtable reqParams = new Hashtable();
225 reqParams["agentID"] = agentID.ToString();
226 reqParams["friendID"] = exFriendID.ToString();
227
228 IList parameters = new ArrayList();
229 parameters.Add(reqParams);
230 try
231 {
232 XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters);
233 XmlRpcResponse response = request.Send(httpServer, 5000);
234 Hashtable respData = (Hashtable)response.Value;
235
236 return (bool)respData["success"];
237 }
238 catch (Exception e)
239 {
240 m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e);
241 return false;
242 }
243 }
244
245 #endregion
246
247 #region Incoming XMLRPC messages
161 /// <summary> 248 /// <summary>
162 /// Receive presence information changes about clients in other regions. 249 /// Receive presence information changes about clients in other regions.
163 /// </summary> 250 /// </summary>
@@ -264,6 +351,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
264 return response; 351 return response;
265 } 352 }
266 353
354 #endregion
355
356 #region Scene events
357
267 private void OnNewClient(IClientAPI client) 358 private void OnNewClient(IClientAPI client)
268 { 359 {
269 // All friends establishment protocol goes over instant message 360 // All friends establishment protocol goes over instant message
@@ -331,6 +422,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
331 } 422 }
332 } 423 }
333 } 424 }
425 #endregion
334 426
335 private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) 427 private ScenePresence GetRootPresenceFromAgentID(UUID AgentID)
336 { 428 {
@@ -681,7 +773,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
681 agentID, exfriendID, data.Handle); 773 agentID, exfriendID, data.Handle);
682 774
683 // try to send to foreign region, retry if it fails (friend TPed away, for example) 775 // try to send to foreign region, retry if it fails (friend TPed away, for example)
684 if (m_initialScene.TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; 776 if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break;
685 } 777 }
686 } 778 }
687 779
@@ -942,7 +1034,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
942 //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line", 1034 //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line",
943 // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off"); 1035 // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off");
944 1036
945 friendIDsToSendTo.AddRange(m_initialScene.InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); 1037 friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline));
946 } 1038 }
947 } 1039 }
948 // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them. 1040 // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them.