aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorMelanie2009-12-28 23:42:08 +0000
committerMelanie2009-12-28 23:42:08 +0000
commite0fc854f05b137c353196356e5b26d11b6ee6867 (patch)
tree9a1c0a29178a9f3e10b10f5e184f46bce1c61078 /OpenSim/Services
parentAdd the second step of the friends migration to pull data from the old table ... (diff)
downloadopensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.zip
opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.gz
opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.bz2
opensim-SC-e0fc854f05b137c353196356e5b26d11b6ee6867.tar.xz
Adding new fields and home location methid to presence. Adding cleanup
(deleting all but one presence record) on logout so that they don't pile up.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs46
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs4
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs34
3 files changed, 80 insertions, 4 deletions
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
index 4ad457f..482862d 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -371,6 +371,52 @@ namespace OpenSim.Services.Connectors
371 } 371 }
372 372
373 373
374 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
375 {
376 Dictionary<string, object> sendData = new Dictionary<string, object>();
377 //sendData["SCOPEID"] = scopeID.ToString();
378 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
379 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
380 sendData["METHOD"] = "sethome";
381
382 sendData["UserID"] = userID;
383 sendData["RegionID"] = regionID.ToString();
384 sendData["position"] = position.ToString();
385 sendData["lookAt"] = lookAt.ToString();
386
387 string reqString = ServerUtils.BuildQueryString(sendData);
388 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
389 try
390 {
391 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
392 m_ServerURI + "/presence",
393 reqString);
394 if (reply != string.Empty)
395 {
396 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
397
398 if (replyData.ContainsKey("Result"))
399 {
400 if (replyData["Result"].ToString().ToLower() == "success")
401 return true;
402 else
403 return false;
404 }
405 else
406 m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation reply data does not contain result field");
407
408 }
409 else
410 m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation received empty reply");
411 }
412 catch (Exception e)
413 {
414 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
415 }
416
417 return false;
418 }
419
374 #endregion 420 #endregion
375 421
376 } 422 }
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs
index de3813a..2582648 100644
--- a/OpenSim/Services/Interfaces/IPresenceService.cs
+++ b/OpenSim/Services/Interfaces/IPresenceService.cs
@@ -41,6 +41,9 @@ namespace OpenSim.Services.Interfaces
41 public DateTime Logout; 41 public DateTime Logout;
42 public Vector3 Position; 42 public Vector3 Position;
43 public Vector3 LookAt; 43 public Vector3 LookAt;
44 public UUID HomeRegionID;
45 public Vector3 HomePosition;
46 public Vector3 HomeLookAt;
44 47
45 public PresenceInfo() 48 public PresenceInfo()
46 { 49 {
@@ -87,6 +90,7 @@ namespace OpenSim.Services.Interfaces
87 bool LogoutRegionAgents(UUID regionID); 90 bool LogoutRegionAgents(UUID regionID);
88 91
89 bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt); 92 bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt);
93 bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt);
90 94
91 PresenceInfo GetAgent(UUID sessionID); 95 PresenceInfo GetAgent(UUID sessionID);
92 PresenceInfo[] GetAgents(string[] userIDs); 96 PresenceInfo[] GetAgents(string[] userIDs);
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index adbf430..b3d8194 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -54,9 +54,10 @@ namespace OpenSim.Services.PresenceService
54 public bool LoginAgent(string userID, UUID sessionID, 54 public bool LoginAgent(string userID, UUID sessionID,
55 UUID secureSessionID) 55 UUID secureSessionID)
56 { 56 {
57 // We have just logged in. If there is any info in the table 57 m_Database.Prune(userID);
58 // it's OK to overwrite. So we won't bother reading it first 58
59 // 59 PresenceData[] d = m_Database.Get("UserID", userID);
60
60 PresenceData data = new PresenceData(); 61 PresenceData data = new PresenceData();
61 62
62 data.UserID = userID; 63 data.UserID = userID;
@@ -64,6 +65,12 @@ namespace OpenSim.Services.PresenceService
64 data.SessionID = sessionID; 65 data.SessionID = sessionID;
65 data.Data["SecureSessionID"] = secureSessionID.ToString(); 66 data.Data["SecureSessionID"] = secureSessionID.ToString();
66 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); 67 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
68 if (d.Length > 0)
69 {
70 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
71 data.Data["HomePosition"] = d[0].Data["HomePosition"];
72 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
73 }
67 74
68 m_Database.Store(data); 75 m_Database.Store(data);
69 76
@@ -76,12 +83,20 @@ namespace OpenSim.Services.PresenceService
76 if (data == null) 83 if (data == null)
77 return false; 84 return false;
78 85
86 PresenceData[] d = m_Database.Get("UserID", data.UserID);
87
88 if (d.Length > 1)
89 {
90 m_Database.Delete("SessionID", sessionID.ToString());
91 return true;
92 }
93
79 data.Data["Online"] = "false"; 94 data.Data["Online"] = "false";
80 data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString(); 95 data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
81 96
82 m_Database.Store(data); 97 m_Database.Store(data);
83 98
84 return false; 99 return true;
85 } 100 }
86 101
87 public bool LogoutRegionAgents(UUID regionID) 102 public bool LogoutRegionAgents(UUID regionID)
@@ -114,6 +129,9 @@ namespace OpenSim.Services.PresenceService
114 ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"])); 129 ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"]));
115 ret.Position = Vector3.Parse(data.Data["Position"]); 130 ret.Position = Vector3.Parse(data.Data["Position"]);
116 ret.LookAt = Vector3.Parse(data.Data["LookAt"]); 131 ret.LookAt = Vector3.Parse(data.Data["LookAt"]);
132 ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]);
133 ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]);
134 ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]);
117 135
118 return ret; 136 return ret;
119 } 137 }
@@ -140,6 +158,9 @@ namespace OpenSim.Services.PresenceService
140 d.Data["Logout"])); 158 d.Data["Logout"]));
141 ret.Position = Vector3.Parse(d.Data["Position"]); 159 ret.Position = Vector3.Parse(d.Data["Position"]);
142 ret.LookAt = Vector3.Parse(d.Data["LookAt"]); 160 ret.LookAt = Vector3.Parse(d.Data["LookAt"]);
161 ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]);
162 ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]);
163 ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]);
143 164
144 info.Add(ret); 165 info.Add(ret);
145 } 166 }
@@ -147,5 +168,10 @@ namespace OpenSim.Services.PresenceService
147 168
148 return info.ToArray(); 169 return info.ToArray();
149 } 170 }
171
172 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
173 {
174 return m_Database.SetHomeLocation(userID, regionID, position, lookAt);
175 }
150 } 176 }
151} 177}