aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/PresenceService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/PresenceService')
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs40
1 files changed, 31 insertions, 9 deletions
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index fc6a6e1..7da0f23 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -63,15 +63,22 @@ namespace OpenSim.Services.PresenceService
63 data.UserID = userID; 63 data.UserID = userID;
64 data.RegionID = UUID.Zero; 64 data.RegionID = UUID.Zero;
65 data.SessionID = sessionID; 65 data.SessionID = sessionID;
66 data.Data = new Dictionary<string, string>();
66 data.Data["SecureSessionID"] = secureSessionID.ToString(); 67 data.Data["SecureSessionID"] = secureSessionID.ToString();
67 data.Data["Online"] = "true"; 68 data.Data["Online"] = "true";
68 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString(); 69 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
69 if (d.Length > 0) 70 if (d != null && d.Length > 0)
70 { 71 {
71 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"]; 72 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
72 data.Data["HomePosition"] = d[0].Data["HomePosition"]; 73 data.Data["HomePosition"] = d[0].Data["HomePosition"];
73 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"]; 74 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
74 } 75 }
76 else
77 {
78 data.Data["HomeRegionID"] = UUID.Zero.ToString();
79 data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString();
80 data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString();
81 }
75 82
76 m_Database.Store(data); 83 m_Database.Store(data);
77 84
@@ -86,9 +93,10 @@ namespace OpenSim.Services.PresenceService
86 93
87 PresenceData[] d = m_Database.Get("UserID", data.UserID); 94 PresenceData[] d = m_Database.Get("UserID", data.UserID);
88 95
96 m_log.WarnFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length);
89 if (d.Length > 1) 97 if (d.Length > 1)
90 { 98 {
91 m_Database.Delete("SessionID", sessionID.ToString()); 99 m_Database.Delete("UserID", data.UserID);
92 } 100 }
93 101
94 data.Data["Online"] = "false"; 102 data.Data["Online"] = "false";
@@ -110,14 +118,28 @@ namespace OpenSim.Services.PresenceService
110 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 118 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
111 { 119 {
112 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); 120 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
113 PresenceData pdata = m_Database.Get(sessionID); 121 try
114 if (pdata == null) 122 {
115 return false; 123 PresenceData pdata = m_Database.Get(sessionID);
116 if (pdata.Data["Online"] == "false") 124 if (pdata == null)
117 return false; 125 return false;
126 if (pdata.Data == null)
127 return false;
128
129 if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false"))
130 {
131 m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online");
132 return false;
133 }
118 134
119 return m_Database.ReportAgent(sessionID, regionID, 135 return m_Database.ReportAgent(sessionID, regionID,
120 position.ToString(), lookAt.ToString()); 136 position.ToString(), lookAt.ToString());
137 }
138 catch (Exception e)
139 {
140 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent threw exception {0}", e.StackTrace);
141 return false;
142 }
121 } 143 }
122 144
123 public PresenceInfo GetAgent(UUID sessionID) 145 public PresenceInfo GetAgent(UUID sessionID)