30 using System.Collections.Generic;
32 using System.Reflection;
34 using OpenSim.Framework;
36 using OpenSim.Framework.ServiceAuth;
37 using OpenSim.Services.Interfaces;
39 using OpenSim.Server.Base;
42 namespace OpenSim.Services.Connectors
46 private static readonly ILog m_log =
48 MethodBase.GetCurrentMethod().DeclaringType);
50 private string m_ServerURI = String.Empty;
58 m_ServerURI = serverURI.TrimEnd(
'/');
68 IConfig gridConfig = source.Configs[
"GridUserService"];
69 if (gridConfig == null)
71 m_log.Error(
"[GRID USER CONNECTOR]: GridUserService missing from OpenSim.ini");
72 throw new Exception(
"GridUser connector init error");
75 string serviceURI = gridConfig.GetString(
"GridUserServerURI",
78 if (serviceURI == String.Empty)
80 m_log.Error(
"[GRID USER CONNECTOR]: No Server URI named in section GridUserService");
81 throw new Exception(
"GridUser connector init error");
83 m_ServerURI = serviceURI;
84 base.Initialise(source,
"GridUserService");
88 #region IGridUserService
93 Dictionary<string, object> sendData =
new Dictionary<string, object>();
95 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
96 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
97 sendData[
"METHOD"] =
"loggedin";
99 sendData[
"UserID"] = userID;
101 return Get(sendData);
105 public bool LoggedOut(
string userID, UUID sessionID, UUID region, Vector3 position, Vector3 lookat)
107 Dictionary<string, object> sendData =
new Dictionary<string, object>();
109 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
110 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
111 sendData[
"METHOD"] =
"loggedout";
113 return Set(sendData, userID, region, position, lookat);
116 public bool SetHome(
string userID, UUID regionID, Vector3 position, Vector3 lookAt)
118 Dictionary<string, object> sendData =
new Dictionary<string, object>();
120 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
121 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
122 sendData[
"METHOD"] =
"sethome";
124 return Set(sendData, userID, regionID, position, lookAt);
127 public bool SetLastPosition(
string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
129 Dictionary<string, object> sendData =
new Dictionary<string, object>();
131 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
132 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
133 sendData[
"METHOD"] =
"setposition";
135 return Set(sendData, userID, regionID, position, lookAt);
140 Dictionary<string, object> sendData =
new Dictionary<string, object>();
142 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
143 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
144 sendData[
"METHOD"] =
"getgriduserinfo";
146 sendData[
"UserID"] = userID;
148 return Get(sendData);
153 protected bool Set(Dictionary<string, object> sendData,
string userID, UUID regionID, Vector3 position, Vector3 lookAt)
155 sendData[
"UserID"] = userID;
156 sendData[
"RegionID"] = regionID.ToString();
157 sendData[
"Position"] = position.ToString();
158 sendData[
"LookAt"] = lookAt.ToString();
160 string reqString = ServerUtils.BuildQueryString(sendData);
161 string uri = m_ServerURI +
"/griduser";
165 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST",
169 if (reply !=
string.Empty)
171 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
173 if (replyData.ContainsKey(
"result"))
175 if (replyData[
"result"].ToString().ToLower() ==
"success")
181 m_log.DebugFormat(
"[GRID USER CONNECTOR]: SetPosition reply data does not contain result field");
185 m_log.DebugFormat(
"[GRID USER CONNECTOR]: SetPosition received empty reply");
189 m_log.DebugFormat(
"[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message);
197 string reqString = ServerUtils.BuildQueryString(sendData);
198 string uri = m_ServerURI +
"/griduser";
202 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST",
206 if (reply !=
string.Empty)
208 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
211 if ((replyData != null) && replyData.ContainsKey(
"result") && (replyData[
"result"] != null))
213 if (replyData[
"result"] is Dictionary<string, object>)
214 guinfo = Create((Dictionary<string, object>)replyData[
"result"]);
221 m_log.DebugFormat(
"[GRID USER CONNECTOR]: Get received empty reply");
225 m_log.DebugFormat(
"[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message);
234 Dictionary<string, object> sendData =
new Dictionary<string, object>();
236 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
237 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
238 sendData[
"METHOD"] =
"getgriduserinfos";
240 sendData[
"AgentIDs"] =
new List<string>(userIDs);
242 string reply = string.Empty;
243 string reqString = ServerUtils.BuildQueryString(sendData);
244 string uri = m_ServerURI +
"/griduser";
248 reply = SynchronousRestFormsRequester.MakeRequest(
"POST",
252 if (reply == null || (reply != null && reply ==
string.Empty))
254 m_log.DebugFormat(
"[GRID USER CONNECTOR]: GetGridUserInfo received null or empty reply");
260 m_log.DebugFormat(
"[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message);
263 List<GridUserInfo> rinfos =
new List<GridUserInfo>();
265 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
267 if (replyData != null)
269 if (replyData.ContainsKey(
"result") &&
270 (replyData[
"result"].ToString() ==
"null" || replyData[
"result"].ToString() ==
"Failure"))
275 Dictionary<string, object>.ValueCollection pinfosList = replyData.Values;
277 foreach (
object griduser
in pinfosList)
279 if (griduser is Dictionary<string, object>)
281 GridUserInfo pinfo = Create((Dictionary<string, object>)griduser);
285 m_log.DebugFormat(
"[GRID USER CONNECTOR]: GetGridUserInfo received invalid response type {0}",
290 m_log.DebugFormat(
"[GRID USER CONNECTOR]: GetGridUserInfo received null response");
292 return rinfos.ToArray();
virtual void Initialise(IConfigSource source)
bool Set(Dictionary< string, object > sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt)
GridUserServicesConnector()
GridUserInfo Get(Dictionary< string, object > sendData)
GridUserServicesConnector(IConfigSource source)
virtual GridUserInfo Create(Dictionary< string, object > griduser)
Records user information specific to a grid but which is not part of a user's account.
GridUserInfo LoggedIn(string userID)
OpenSim.Services.Interfaces.GridRegion GridRegion
GridUserServicesConnector(string serverURI)
bool LoggedOut(string userID, UUID sessionID, UUID region, Vector3 position, Vector3 lookat)
Informs the grid that a user is logged out and to remove any session data for them ...
bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
Stores the last known user position at the grid level
GridUserInfo[] GetGridUserInfo(string[] userIDs)
GridUserInfo GetGridUserInfo(string userID)