30 using System.Collections.Generic;
32 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Framework.ServiceAuth;
36 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(
'/');
62 : base(source,
"AvatarService")
69 IConfig gridConfig = source.Configs[
"AvatarService"];
70 if (gridConfig == null)
72 m_log.Error(
"[AVATAR CONNECTOR]: AvatarService missing from OpenSim.ini");
73 throw new Exception(
"Avatar connector init error");
76 string serviceURI = gridConfig.GetString(
"AvatarServerURI",
79 if (serviceURI == String.Empty)
81 m_log.Error(
"[AVATAR CONNECTOR]: No Server URI named in section AvatarService");
82 throw new Exception(
"Avatar connector init error");
84 m_ServerURI = serviceURI;
86 base.Initialise(source,
"AvatarService");
90 #region IAvatarService
95 return avatar.ToAvatarAppearance();
101 return SetAvatar(userID,avatar);
106 Dictionary<string, object> sendData =
new Dictionary<string, object>();
108 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
109 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
110 sendData[
"METHOD"] =
"getavatar";
112 sendData[
"UserID"] = userID;
114 string reply = string.Empty;
115 string reqString = ServerUtils.BuildQueryString(sendData);
116 string uri = m_ServerURI +
"/avatar";
120 reply = SynchronousRestFormsRequester.MakeRequest(
"POST", uri, reqString, m_Auth);
121 if (reply == null || (reply != null && reply ==
string.Empty))
123 m_log.DebugFormat(
"[AVATAR CONNECTOR]: GetAgent received null or empty reply");
129 m_log.DebugFormat(
"[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
132 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
135 if ((replyData != null) && replyData.ContainsKey(
"result") && (replyData[
"result"] != null))
137 if (replyData[
"result"] is Dictionary<string, object>)
139 avatar =
new AvatarData((Dictionary<string, object>)replyData[
"result"]);
149 Dictionary<string, object> sendData =
new Dictionary<string, object>();
151 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
152 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
153 sendData[
"METHOD"] =
"setavatar";
155 sendData[
"UserID"] = userID.ToString();
157 Dictionary<string, object> structData = avatar.ToKeyValuePairs();
159 foreach (KeyValuePair<string, object> kvp
in structData)
160 sendData[kvp.Key] = kvp.Value.ToString();
163 string reqString = ServerUtils.BuildQueryString(sendData);
164 string uri = m_ServerURI +
"/avatar";
168 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST", uri, reqString, m_Auth);
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")
182 m_log.DebugFormat(
"[AVATAR CONNECTOR]: SetAvatar reply data does not contain result field");
187 m_log.DebugFormat(
"[AVATAR CONNECTOR]: SetAvatar received empty reply");
192 m_log.DebugFormat(
"[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
200 Dictionary<string, object> sendData =
new Dictionary<string, object>();
202 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
203 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
204 sendData[
"METHOD"] =
"resetavatar";
206 sendData[
"UserID"] = userID.ToString();
208 string reqString = ServerUtils.BuildQueryString(sendData);
209 string uri = m_ServerURI +
"/avatar";
213 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST", uri, reqString, m_Auth);
214 if (reply !=
string.Empty)
216 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
218 if (replyData.ContainsKey(
"result"))
220 if (replyData[
"result"].ToString().ToLower() ==
"success")
226 m_log.DebugFormat(
"[AVATAR CONNECTOR]: SetItems reply data does not contain result field");
230 m_log.DebugFormat(
"[AVATAR CONNECTOR]: SetItems received empty reply");
234 m_log.DebugFormat(
"[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
240 public bool SetItems(UUID userID,
string[] names,
string[] values)
242 Dictionary<string, object> sendData =
new Dictionary<string, object>();
243 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
244 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
245 sendData[
"METHOD"] =
"setitems";
247 sendData[
"UserID"] = userID.ToString();
248 sendData[
"Names"] =
new List<string>(names);
249 sendData[
"Values"] =
new List<string>(values);
251 string reqString = ServerUtils.BuildQueryString(sendData);
252 string uri = m_ServerURI +
"/avatar";
256 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST", uri, reqString, m_Auth);
257 if (reply !=
string.Empty)
259 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
261 if (replyData.ContainsKey(
"result"))
263 if (replyData[
"result"].ToString().ToLower() ==
"success")
269 m_log.DebugFormat(
"[AVATAR CONNECTOR]: SetItems reply data does not contain result field");
273 m_log.DebugFormat(
"[AVATAR CONNECTOR]: SetItems received empty reply");
277 m_log.DebugFormat(
"[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
285 Dictionary<string, object> sendData =
new Dictionary<string, object>();
287 sendData[
"VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
288 sendData[
"VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
289 sendData[
"METHOD"] =
"removeitems";
291 sendData[
"UserID"] = userID.ToString();
292 sendData[
"Names"] =
new List<string>(names);
294 string reqString = ServerUtils.BuildQueryString(sendData);
295 string uri = m_ServerURI +
"/avatar";
299 string reply = SynchronousRestFormsRequester.MakeRequest(
"POST", uri, reqString, m_Auth);
300 if (reply !=
string.Empty)
302 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
304 if (replyData.ContainsKey(
"result"))
306 if (replyData[
"result"].ToString().ToLower() ==
"success")
312 m_log.DebugFormat(
"[AVATAR CONNECTOR]: RemoveItems reply data does not contain result field");
316 m_log.DebugFormat(
"[AVATAR CONNECTOR]: RemoveItems received empty reply");
320 m_log.DebugFormat(
"[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message);
bool SetAppearance(UUID userID, AvatarAppearance appearance)
Called by everyone who can change the avatar data (so, regions)
Contains the Avatar's Appearance and methods to manipulate the appearance.
AvatarAppearance GetAppearance(UUID userID)
Called by the login service
OpenSim.Services.Interfaces.IAvatarService IAvatarService
virtual void Initialise(IConfigSource source)
AvatarServicesConnector(IConfigSource source)
bool SetAvatar(UUID userID, AvatarData avatar)
Called by everyone who can change the avatar data (so, regions)
AvatarServicesConnector(string serverURI)
bool RemoveItems(UUID userID, string[] names)
OpenSim.Services.Interfaces.GridRegion GridRegion
AvatarData GetAvatar(UUID userID)
Called by the login service
Each region/client that uses avatars will have a data structure of this type representing the avatars...
bool ResetAvatar(UUID userID)
Not sure if it's needed
bool SetItems(UUID userID, string[] names, string[] values)
These methods raison d'etre: No need to send the entire avatar data (SetAvatar) for changing attachme...
AvatarServicesConnector()