aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/PresenceService
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/PresenceService')
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs146
-rw-r--r--OpenSim/Services/PresenceService/PresenceServiceBase.cs2
2 files changed, 136 insertions, 12 deletions
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index 2157462..fc6a6e1 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -41,27 +41,151 @@ namespace OpenSim.Services.PresenceService
41{ 41{
42 public class PresenceService : PresenceServiceBase, IPresenceService 42 public class PresenceService : PresenceServiceBase, IPresenceService
43 { 43 {
44// private static readonly ILog m_log = 44 private static readonly ILog m_log =
45// LogManager.GetLogger( 45 LogManager.GetLogger(
46// MethodBase.GetCurrentMethod().DeclaringType); 46 MethodBase.GetCurrentMethod().DeclaringType);
47 47
48 public PresenceService(IConfigSource config) 48 public PresenceService(IConfigSource config)
49 : base(config) 49 : base(config)
50 { 50 {
51 m_log.Debug("[PRESENCE SERVICE]: Starting presence service");
51 } 52 }
52 53
53 public bool Report(PresenceInfo presence) 54 public bool LoginAgent(string userID, UUID sessionID,
55 UUID secureSessionID)
54 { 56 {
55 PresenceData p = new PresenceData(); 57 m_Database.Prune(userID);
56 p.Data = new Dictionary<string, string>();
57 58
58 p.UUID = presence.PrincipalID; 59 PresenceData[] d = m_Database.Get("UserID", userID);
59 p.currentRegion = presence.RegionID;
60 60
61 foreach (KeyValuePair<string, string> kvp in presence.Data) 61 PresenceData data = new PresenceData();
62 p.Data[kvp.Key] = kvp.Value;
63 62
64 return false; 63 data.UserID = userID;
64 data.RegionID = UUID.Zero;
65 data.SessionID = sessionID;
66 data.Data["SecureSessionID"] = secureSessionID.ToString();
67 data.Data["Online"] = "true";
68 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
69 if (d.Length > 0)
70 {
71 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
72 data.Data["HomePosition"] = d[0].Data["HomePosition"];
73 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
74 }
75
76 m_Database.Store(data);
77
78 return true;
79 }
80
81 public bool LogoutAgent(UUID sessionID)
82 {
83 PresenceData data = m_Database.Get(sessionID);
84 if (data == null)
85 return false;
86
87 PresenceData[] d = m_Database.Get("UserID", data.UserID);
88
89 if (d.Length > 1)
90 {
91 m_Database.Delete("SessionID", sessionID.ToString());
92 }
93
94 data.Data["Online"] = "false";
95 data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
96
97 m_Database.Store(data);
98
99 return true;
100 }
101
102 public bool LogoutRegionAgents(UUID regionID)
103 {
104 m_Database.LogoutRegionAgents(regionID);
105
106 return true;
107 }
108
109
110 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
111 {
112 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
113 PresenceData pdata = m_Database.Get(sessionID);
114 if (pdata == null)
115 return false;
116 if (pdata.Data["Online"] == "false")
117 return false;
118
119 return m_Database.ReportAgent(sessionID, regionID,
120 position.ToString(), lookAt.ToString());
121 }
122
123 public PresenceInfo GetAgent(UUID sessionID)
124 {
125 PresenceInfo ret = new PresenceInfo();
126
127 PresenceData data = m_Database.Get(sessionID);
128 if (data == null)
129 return null;
130
131 ret.UserID = data.UserID;
132 ret.RegionID = data.RegionID;
133 if (data.Data.ContainsKey("Online"))
134 ret.Online = bool.Parse(data.Data["Online"]);
135 if (data.Data.ContainsKey("Login"))
136 ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"]));
137 if (data.Data.ContainsKey("Logout"))
138 ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"]));
139 if (data.Data.ContainsKey("Position"))
140 ret.Position = Vector3.Parse(data.Data["Position"]);
141 if (data.Data.ContainsKey("LookAt"))
142 ret.LookAt = Vector3.Parse(data.Data["LookAt"]);
143 if (data.Data.ContainsKey("HomeRegionID"))
144 ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]);
145 if (data.Data.ContainsKey("HomePosition"))
146 ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]);
147 if (data.Data.ContainsKey("HomeLookAt"))
148 ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]);
149
150 return ret;
151 }
152
153 public PresenceInfo[] GetAgents(string[] userIDs)
154 {
155 List<PresenceInfo> info = new List<PresenceInfo>();
156
157 foreach (string userIDStr in userIDs)
158 {
159 PresenceData[] data = m_Database.Get("UserID",
160 userIDStr);
161
162 foreach (PresenceData d in data)
163 {
164 PresenceInfo ret = new PresenceInfo();
165
166 ret.UserID = d.UserID;
167 ret.RegionID = d.RegionID;
168 ret.Online = bool.Parse(d.Data["Online"]);
169 ret.Login = Util.ToDateTime(Convert.ToInt32(
170 d.Data["Login"]));
171 ret.Logout = Util.ToDateTime(Convert.ToInt32(
172 d.Data["Logout"]));
173 ret.Position = Vector3.Parse(d.Data["Position"]);
174 ret.LookAt = Vector3.Parse(d.Data["LookAt"]);
175 ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]);
176 ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]);
177 ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]);
178
179 info.Add(ret);
180 }
181 }
182
183 return info.ToArray();
184 }
185
186 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
187 {
188 return m_Database.SetHomeLocation(userID, regionID, position, lookAt);
65 } 189 }
66 } 190 }
67} 191}
diff --git a/OpenSim/Services/PresenceService/PresenceServiceBase.cs b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
index 60a246b..3ca70c1 100644
--- a/OpenSim/Services/PresenceService/PresenceServiceBase.cs
+++ b/OpenSim/Services/PresenceService/PresenceServiceBase.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Services.PresenceService
44 { 44 {
45 string dllName = String.Empty; 45 string dllName = String.Empty;
46 string connString = String.Empty; 46 string connString = String.Empty;
47 string realm = "agents"; 47 string realm = "presence";
48 48
49 // 49 //
50 // Try reading the [DatabaseService] section, if it exists 50 // Try reading the [DatabaseService] section, if it exists