aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs196
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs54
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs88
3 files changed, 278 insertions, 60 deletions
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
index 0e85067..b4500a5 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
@@ -25,14 +25,206 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using log4net;
28using System; 29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using OpenMetaverse;
29 41
30namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
31{ 43{
32 public class GridUserServiceConnector 44 public class GridUserServicesConnector : IGridUserService
33 { 45 {
34 public GridUserServiceConnector() 46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 public GridUserServicesConnector()
53 {
54 }
55
56 public GridUserServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public GridUserServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig gridConfig = source.Configs["GridUserService"];
69 if (gridConfig == null)
70 {
71 m_log.Error("[GRID USER CONNECTOR]: GridUserService missing from OpenSim.ini");
72 throw new Exception("GridUser connector init error");
73 }
74
75 string serviceURI = gridConfig.GetString("GridUserServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[GRID USER CONNECTOR]: No Server URI named in section GridUserService");
81 throw new Exception("GridUser connector init error");
82 }
83 m_ServerURI = serviceURI;
84 }
85
86
87 #region IPresenceService
88
89
90 public GridUserInfo LoggedIn(string userID)
91 {
92 Dictionary<string, object> sendData = new Dictionary<string, object>();
93 //sendData["SCOPEID"] = scopeID.ToString();
94 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
95 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
96 sendData["METHOD"] = "loggedin";
97
98 sendData["UserID"] = userID;
99
100 return Get(sendData);
101
102 }
103
104 public bool LoggedOut(string userID, UUID region, Vector3 position, Vector3 lookat)
105 {
106 Dictionary<string, object> sendData = new Dictionary<string, object>();
107 //sendData["SCOPEID"] = scopeID.ToString();
108 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
109 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
110 sendData["METHOD"] = "loggedout";
111
112 return Set(sendData, userID, region, position, lookat);
113 }
114
115 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
116 {
117 Dictionary<string, object> sendData = new Dictionary<string, object>();
118 //sendData["SCOPEID"] = scopeID.ToString();
119 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
120 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
121 sendData["METHOD"] = "sethome";
122
123 return Set(sendData, userID, regionID, position, lookAt);
124 }
125
126 public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
127 {
128 Dictionary<string, object> sendData = new Dictionary<string, object>();
129 //sendData["SCOPEID"] = scopeID.ToString();
130 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
131 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
132 sendData["METHOD"] = "setposition";
133
134 return Set(sendData, userID, regionID, position, lookAt);
135 }
136
137 public GridUserInfo GetGridUserInfo(string userID)
138 {
139 Dictionary<string, object> sendData = new Dictionary<string, object>();
140 //sendData["SCOPEID"] = scopeID.ToString();
141 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
142 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
143 sendData["METHOD"] = "getgriduserinfo";
144
145 sendData["UserID"] = userID;
146
147 return Get(sendData);
148 }
149
150 #endregion
151
152 protected bool Set(Dictionary<string, object> sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt)
153 {
154 sendData["UserID"] = userID;
155 sendData["RegionID"] = regionID.ToString();
156 sendData["Position"] = position.ToString();
157 sendData["LookAt"] = lookAt.ToString();
158
159 string reqString = ServerUtils.BuildQueryString(sendData);
160 // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
161 try
162 {
163 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
164 m_ServerURI + "/griduser",
165 reqString);
166 if (reply != string.Empty)
167 {
168 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
169
170 if (replyData.ContainsKey("result"))
171 {
172 if (replyData["result"].ToString().ToLower() == "success")
173 return true;
174 else
175 return false;
176 }
177 else
178 m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition reply data does not contain result field");
179
180 }
181 else
182 m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition received empty reply");
183 }
184 catch (Exception e)
185 {
186 m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message);
187 }
188
189 return false;
190 }
191
192 protected GridUserInfo Get(Dictionary<string, object> sendData)
35 { 193 {
194 string reqString = ServerUtils.BuildQueryString(sendData);
195 // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
196 try
197 {
198 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
199 m_ServerURI + "/griduser",
200 reqString);
201 if (reply != string.Empty)
202 {
203 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
204 GridUserInfo guinfo = null;
205
206 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
207 {
208 if (replyData["result"] is Dictionary<string, object>)
209 {
210 guinfo = new GridUserInfo((Dictionary<string, object>)replyData["result"]);
211 }
212 }
213
214 return guinfo;
215
216 }
217 else
218 m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply");
219 }
220 catch (Exception e)
221 {
222 m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message);
223 }
224
225 return null;
226
36 } 227 }
228
37 } 229 }
38} 230}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
index 23621b7..41ebeaf 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Services.Connectors
132 132
133 } 133 }
134 134
135 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) 135 public bool LogoutAgent(UUID sessionID)
136 { 136 {
137 Dictionary<string, object> sendData = new Dictionary<string, object>(); 137 Dictionary<string, object> sendData = new Dictionary<string, object>();
138 //sendData["SCOPEID"] = scopeID.ToString(); 138 //sendData["SCOPEID"] = scopeID.ToString();
@@ -141,8 +141,6 @@ namespace OpenSim.Services.Connectors
141 sendData["METHOD"] = "logout"; 141 sendData["METHOD"] = "logout";
142 142
143 sendData["SessionID"] = sessionID.ToString(); 143 sendData["SessionID"] = sessionID.ToString();
144 sendData["Position"] = position.ToString();
145 sendData["LookAt"] = lookat.ToString();
146 144
147 string reqString = ServerUtils.BuildQueryString(sendData); 145 string reqString = ServerUtils.BuildQueryString(sendData);
148 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); 146 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
@@ -220,7 +218,7 @@ namespace OpenSim.Services.Connectors
220 return false; 218 return false;
221 } 219 }
222 220
223 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 221 public bool ReportAgent(UUID sessionID, UUID regionID)
224 { 222 {
225 Dictionary<string, object> sendData = new Dictionary<string, object>(); 223 Dictionary<string, object> sendData = new Dictionary<string, object>();
226 //sendData["SCOPEID"] = scopeID.ToString(); 224 //sendData["SCOPEID"] = scopeID.ToString();
@@ -230,8 +228,6 @@ namespace OpenSim.Services.Connectors
230 228
231 sendData["SessionID"] = sessionID.ToString(); 229 sendData["SessionID"] = sessionID.ToString();
232 sendData["RegionID"] = regionID.ToString(); 230 sendData["RegionID"] = regionID.ToString();
233 sendData["position"] = position.ToString();
234 sendData["lookAt"] = lookAt.ToString();
235 231
236 string reqString = ServerUtils.BuildQueryString(sendData); 232 string reqString = ServerUtils.BuildQueryString(sendData);
237 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); 233 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
@@ -371,52 +367,6 @@ namespace OpenSim.Services.Connectors
371 } 367 }
372 368
373 369
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
420 #endregion 370 #endregion
421 371
422 } 372 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index c324272..e48b7de 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
51 /// message routing) to the SimianGrid backend 51 /// message routing) to the SimianGrid backend
52 /// </summary> 52 /// </summary>
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
54 public class SimianPresenceServiceConnector : IPresenceService, ISharedRegionModule 54 public class SimianPresenceServiceConnector : IPresenceService, IGridUserService, ISharedRegionModule
55 { 55 {
56 private static readonly ILog m_log = 56 private static readonly ILog m_log =
57 LogManager.GetLogger( 57 LogManager.GetLogger(
@@ -73,6 +73,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
73 if (!String.IsNullOrEmpty(m_serverUrl)) 73 if (!String.IsNullOrEmpty(m_serverUrl))
74 { 74 {
75 scene.RegisterModuleInterface<IPresenceService>(this); 75 scene.RegisterModuleInterface<IPresenceService>(this);
76 scene.RegisterModuleInterface<IGridUserService>(this);
76 77
77 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler; 78 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler;
78 scene.EventManager.OnNewClient += NewClientHandler; 79 scene.EventManager.OnNewClient += NewClientHandler;
@@ -86,6 +87,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
86 if (!String.IsNullOrEmpty(m_serverUrl)) 87 if (!String.IsNullOrEmpty(m_serverUrl))
87 { 88 {
88 scene.UnregisterModuleInterface<IPresenceService>(this); 89 scene.UnregisterModuleInterface<IPresenceService>(this);
90 scene.UnregisterModuleInterface<IGridUserService>(this);
89 91
90 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler; 92 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler;
91 scene.EventManager.OnNewClient -= NewClientHandler; 93 scene.EventManager.OnNewClient -= NewClientHandler;
@@ -151,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
151 return success; 153 return success;
152 } 154 }
153 155
154 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt) 156 public bool LogoutAgent(UUID sessionID)
155 { 157 {
156 m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); 158 m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
157 159
@@ -189,7 +191,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
189 return success; 191 return success;
190 } 192 }
191 193
192 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 194 public bool ReportAgent(UUID sessionID, UUID regionID)
195 {
196 return ReportAgent(sessionID, regionID, Vector3.Zero, Vector3.Zero);
197 }
198
199 protected bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
193 { 200 {
194 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID); 201 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID);
195 202
@@ -261,7 +268,23 @@ namespace OpenSim.Services.Connectors.SimianGrid
261 return presences.ToArray(); 268 return presences.ToArray();
262 } 269 }
263 270
264 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 271 #endregion IPresenceService
272
273 #region IGridUserService
274
275 public GridUserInfo LoggedIn(string userID)
276 {
277 // never implemented at the sim
278 return null;
279 }
280
281 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
282 {
283 // Not needed for simian grid, event handler is doing it
284 return true;
285 }
286
287 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
265 { 288 {
266 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); 289 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
267 290
@@ -281,7 +304,35 @@ namespace OpenSim.Services.Connectors.SimianGrid
281 return success; 304 return success;
282 } 305 }
283 306
284 #endregion IPresenceService 307 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
308 {
309 // Not needed for simian grid, presence detection is doing it
310 return true;
311 }
312
313 public GridUserInfo GetGridUserInfo(string user)
314 {
315 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
316
317 UUID userID = new UUID(user);
318 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
319
320 NameValueCollection requestArgs = new NameValueCollection
321 {
322 { "RequestMethod", "GetUser" },
323 { "UserID", userID.ToString() }
324 };
325
326 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
327 if (userResponse["Success"].AsBoolean())
328 return ResponseToGridUserInfo(userResponse);
329 else
330 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
331
332 return null;
333 }
334
335 #endregion
285 336
286 #region Presence Detection 337 #region Presence Detection
287 338
@@ -325,7 +376,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
325 SetLastLocation(client.SessionId); 376 SetLastLocation(client.SessionId);
326 } 377 }
327 378
328 LogoutAgent(client.SessionId, Vector3.Zero, Vector3.UnitX); 379 LogoutAgent(client.SessionId);
329 } 380 }
330 } 381 }
331 382
@@ -478,6 +529,31 @@ namespace OpenSim.Services.Connectors.SimianGrid
478 return info; 529 return info;
479 } 530 }
480 531
532 private GridUserInfo ResponseToGridUserInfo(OSDMap userResponse)
533 {
534 if (userResponse != null && userResponse["User"] is OSDMap)
535 {
536
537 GridUserInfo info = new GridUserInfo();
538
539 info.Online = true;
540 info.UserID = userResponse["UserID"].AsUUID().ToString();
541 info.LastRegionID = userResponse["SceneID"].AsUUID();
542 info.LastPosition = userResponse["ScenePosition"].AsVector3();
543 info.LastLookAt = userResponse["SceneLookAt"].AsVector3();
544
545 OSDMap user = (OSDMap)userResponse["User"];
546
547 info.Login = user["LastLoginDate"].AsDate();
548 info.Logout = user["LastLogoutDate"].AsDate();
549 DeserializeLocation(user["HomeLocation"].AsString(), out info.HomeRegionID, out info.HomePosition, out info.HomeLookAt);
550
551 return info;
552 }
553
554 return null;
555 }
556
481 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt) 557 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt)
482 { 558 {
483 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}"; 559 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}";