aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/MessagingServer/MessageService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/MessagingServer/MessageService.cs')
-rw-r--r--OpenSim/Grid/MessagingServer/MessageService.cs210
1 files changed, 161 insertions, 49 deletions
diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs
index 31d33b8..4baf51e 100644
--- a/OpenSim/Grid/MessagingServer/MessageService.cs
+++ b/OpenSim/Grid/MessagingServer/MessageService.cs
@@ -61,54 +61,29 @@ namespace OpenSim.Grid.MessagingServer
61 m_cfg = cfg; 61 m_cfg = cfg;
62 } 62 }
63 63
64 public XmlRpcResponse UserLoggedOn(XmlRpcRequest request) 64
65 {
66
67 Hashtable requestData = (Hashtable)request.Params[0];
68 AgentCircuitData agentData = new AgentCircuitData();
69 agentData.SessionID = new LLUUID((string)requestData["session_id"]);
70 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
71 agentData.firstname = (string)requestData["firstname"];
72 agentData.lastname = (string)requestData["lastname"];
73 agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
74 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
75 agentData.CapsPath = (string)requestData["caps_path"];
76
77 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
78 {
79 agentData.child = true;
80 }
81 else
82 {
83 agentData.startpos =
84 new LLVector3(Convert.ToUInt32(requestData["startpos_x"]),
85 Convert.ToUInt32(requestData["startpos_y"]),
86 Convert.ToUInt32(requestData["startpos_z"]));
87 agentData.child = false;
88 }
89
90 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
91
92 UserPresenceData up = new UserPresenceData();
93 up.agentData = agentData;
94 List<FriendListItem> flData = GetUserFriendList(agentData.AgentID);
95 up.friendData = flData;
96 RegionProfileData riData = GetRegionInfo(regionHandle);
97 up.regionData = riData;
98
99 ProcessFriendListSubscriptions(up);
100
101
102 return new XmlRpcResponse();
103 }
104
105 #region RegionComms Methods 65 #region RegionComms Methods
106 66
107 public void SendRegionPresenceUpdate(UserPresenceData AgentData) 67 /// <summary>
68 /// Informs a region about an Agent
69 /// </summary>
70 /// <param name="TalkingAbout">User to talk about</param>
71 /// <param name="UserToUpdate">User we're sending this too (contains the region)</param>
72 public void SendRegionPresenceUpdate(UserPresenceData TalkingAbout, UserPresenceData UserToUpdate)
108 { 73 {
109 RegionProfileData whichRegion = AgentData.regionData; 74 // TODO: Fill in pertenant Presence Data from 'TalkingAbout'
75
76 RegionProfileData whichRegion = UserToUpdate.regionData;
110 //whichRegion.httpServerURI 77 //whichRegion.httpServerURI
111 78
79 Hashtable PresenceParams = new Hashtable();
80 ArrayList SendParams = new ArrayList();
81 SendParams.Add(PresenceParams);
82
83 MainLog.Instance.Verbose("PRESENCE", "Informing " + whichRegion.regionName + " at " + whichRegion.httpServerURI);
84 // Send
85 XmlRpcRequest RegionReq = new XmlRpcRequest("presence_update", SendParams);
86 XmlRpcResponse RegionResp = RegionReq.Send(whichRegion.httpServerURI, 6000);
112 } 87 }
113 88
114 89
@@ -116,8 +91,12 @@ namespace OpenSim.Grid.MessagingServer
116 91
117 #region FriendList Methods 92 #region FriendList Methods
118 93
119 #region FriendListProcessing 94
120 95 /// <summary>
96 /// Process Friendlist subscriptions for a user
97 /// The login method calls this for a User
98 /// </summary>
99 /// <param name="userpresence">The Agent we're processing the friendlist subscriptions</param>
121 public void ProcessFriendListSubscriptions(UserPresenceData userpresence) 100 public void ProcessFriendListSubscriptions(UserPresenceData userpresence)
122 { 101 {
123 List<FriendListItem> uFriendList = userpresence.friendData; 102 List<FriendListItem> uFriendList = userpresence.friendData;
@@ -138,6 +117,15 @@ namespace OpenSim.Grid.MessagingServer
138 m_presences.Add(userpresence.agentData.AgentID, userpresence); 117 m_presences.Add(userpresence.agentData.AgentID, userpresence);
139 } 118 }
140 119
120 /// <summary>
121 /// Does the necessary work to subscribe one agent to another's presence notifications
122 /// Gets called by ProcessFriendListSubscriptions. You shouldn't call this directly
123 /// unless you know what you're doing
124 /// </summary>
125 /// <param name="userpresence">P1</param>
126 /// <param name="friendpresence">P2</param>
127 /// <param name="uFriendListItem"></param>
128 /// <param name="uFriendListIndex"></param>
141 public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence, 129 public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence,
142 FriendListItem uFriendListItem, int uFriendListIndex) 130 FriendListItem uFriendListItem, int uFriendListIndex)
143 { 131 {
@@ -149,12 +137,14 @@ namespace OpenSim.Grid.MessagingServer
149 { 137 {
150 userpresence.subscriptionData.Add(friendpresence.agentData.AgentID); 138 userpresence.subscriptionData.Add(friendpresence.agentData.AgentID);
151 //Send Region Notice.... 139 //Send Region Notice....
140
152 } 141 }
153 else 142 else
154 { 143 {
155 // we need to send out online status update, but the user is already subscribed 144 // we need to send out online status update, but the user is already subscribed
156 145
157 } 146 }
147 SendRegionPresenceUpdate(friendpresence, userpresence);
158 } 148 }
159 if ((uFriendListItem.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0) 149 if ((uFriendListItem.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
160 { 150 {
@@ -168,6 +158,7 @@ namespace OpenSim.Grid.MessagingServer
168 // we need to send out online status update, but the user is already subscribed 158 // we need to send out online status update, but the user is already subscribed
169 159
170 } 160 }
161 SendRegionPresenceUpdate(userpresence, friendpresence);
171 } 162 }
172 163
173 } 164 }
@@ -221,10 +212,54 @@ namespace OpenSim.Grid.MessagingServer
221 } 212 }
222 } 213 }
223 } 214 }
215 /// <summary>
216 /// Logoff Processor. Call this to clean up agent presence data and send logoff presence notifications
217 /// </summary>
218 /// <param name="AgentID"></param>
219 private void ProcessLogOff(LLUUID AgentID)
220 {
221 if (m_presences.Contains(AgentID))
222 {
223 UserPresenceData AgentData = (UserPresenceData)m_presences[AgentID];
224
225 if (m_presence_BackReferences.Contains(AgentID))
226 {
227 List<LLUUID> AgentsNeedingNotification = (List<LLUUID>)m_presence_BackReferences[AgentID];
228 for (int i = 0; i < AgentsNeedingNotification.Count; i++)
229 {
230 // TODO: Do Region Notifications
231 if (m_presences.Contains(AgentsNeedingNotification[i]))
232 {
233 UserPresenceData friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
234
235 // This might need to be enumerated and checked before we try to remove it.
236 friendd.subscriptionData.Remove(AgentID);
237
238 List<FriendListItem> fl = friendd.friendData;
239 for (int j = 0; j < fl.Count; j++)
240 {
241 if (fl[j].Friend == AgentID)
242 {
243 fl[j].onlinestatus = false;
244 }
245
246 }
247 friendd.friendData = fl;
248
249 SendRegionPresenceUpdate(AgentData, friendd);
250
251 }
252 removeBackReference(AgentID, AgentsNeedingNotification[i]);
253
254 }
255 }
256 }
257 }
258
224 259
225 #endregion 260 #endregion
226 261
227 #region FriendList Gathering 262 #region UserServer Comms
228 263
229 /// <summary> 264 /// <summary>
230 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner 265 /// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for LLUUID friendslistowner
@@ -260,6 +295,12 @@ namespace OpenSim.Grid.MessagingServer
260 return buddylist; 295 return buddylist;
261 296
262 } 297 }
298
299 /// <summary>
300 /// Converts XMLRPC Friend List to FriendListItem Object
301 /// </summary>
302 /// <param name="data">XMLRPC response data Hashtable</param>
303 /// <returns></returns>
263 public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data) 304 public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
264 { 305 {
265 List<FriendListItem> buddylist = new List<FriendListItem>(); 306 List<FriendListItem> buddylist = new List<FriendListItem>();
@@ -281,10 +322,75 @@ namespace OpenSim.Grid.MessagingServer
281 322
282 return buddylist; 323 return buddylist;
283 } 324 }
284 #endregion 325 /// <summary>
326 /// UserServer sends an expect_user method
327 /// this handles the method and provisions the
328 /// necessary info for presence to work
329 /// </summary>
330 /// <param name="request">UserServer Data</param>
331 /// <returns></returns>
332 public XmlRpcResponse UserLoggedOn(XmlRpcRequest request)
333 {
285 334
286 #endregion 335 Hashtable requestData = (Hashtable)request.Params[0];
336 AgentCircuitData agentData = new AgentCircuitData();
337 agentData.SessionID = new LLUUID((string)requestData["session_id"]);
338 agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]);
339 agentData.firstname = (string)requestData["firstname"];
340 agentData.lastname = (string)requestData["lastname"];
341 agentData.AgentID = new LLUUID((string)requestData["agent_id"]);
342 agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]);
343 agentData.CapsPath = (string)requestData["caps_path"];
344
345 if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1"))
346 {
347 agentData.child = true;
348 }
349 else
350 {
351 agentData.startpos =
352 new LLVector3(Convert.ToUInt32(requestData["startpos_x"]),
353 Convert.ToUInt32(requestData["startpos_y"]),
354 Convert.ToUInt32(requestData["startpos_z"]));
355 agentData.child = false;
356 }
287 357
358 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
359
360 UserPresenceData up = new UserPresenceData();
361 up.agentData = agentData;
362 List<FriendListItem> flData = GetUserFriendList(agentData.AgentID);
363 up.friendData = flData;
364 RegionProfileData riData = GetRegionInfo(regionHandle);
365 up.regionData = riData;
366
367 ProcessFriendListSubscriptions(up);
368
369
370 return new XmlRpcResponse();
371 }
372
373 /// <summary>
374 /// The UserServer got a Logoff message
375 /// Cleanup time for that user. Send out presence notifications
376 /// </summary>
377 /// <param name="request"></param>
378 /// <returns></returns>
379 public XmlRpcResponse UserLoggedOff(XmlRpcRequest request)
380 {
381
382 Hashtable requestData = (Hashtable)request.Params[0];
383
384 LLUUID AgentID = new LLUUID((string)requestData["agent_id"]);
385
386
387 ProcessLogOff(AgentID);
388
389
390 return new XmlRpcResponse();
391 }
392
393 #endregion
288 #region regioninfo gathering 394 #region regioninfo gathering
289 395
290 /// <summary> 396 /// <summary>
@@ -306,6 +412,12 @@ namespace OpenSim.Grid.MessagingServer
306 } 412 }
307 return regionInfo; 413 return regionInfo;
308 } 414 }
415 /// <summary>
416 /// Get RegionProfileData from the GridServer
417 /// We'll Cache this information and use it for presence updates
418 /// </summary>
419 /// <param name="regionHandle"></param>
420 /// <returns></returns>
309 public RegionProfileData RequestRegionInfo(ulong regionHandle) 421 public RegionProfileData RequestRegionInfo(ulong regionHandle)
310 { RegionProfileData regionProfile = null; 422 { RegionProfileData regionProfile = null;
311 try 423 try