private bool Call(GridRegion region, Dictionary <string, object> sendData) { string reqString = ServerUtils.BuildQueryString(sendData); // m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString); try { string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; string reply = SynchronousRestFormsRequester.MakeRequest("POST", url + "/estate", reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("RESULT")) { if (replyData["RESULT"].ToString().ToLower() == "true") { return(true); } else { return(false); } } else { m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field"); } } else { m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply"); } } catch (Exception e) { m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message); } return(false); }
public bool LogoutAgent(UUID sessionID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); //sendData["SCOPEID"] = scopeID.ToString(); sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); sendData["METHOD"] = "logout"; sendData["SessionID"] = sessionID.ToString(); string reqString = ServerUtils.BuildQueryString(sendData); string uri = m_ServerURI + "/presence"; // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { int indx = reply.IndexOf("success", StringComparison.InvariantCultureIgnoreCase); if (indx > 0) { return(true); } return(false); } else { m_log.DebugFormat("[PRESENCE CONNECTOR]: LogoutAgent received empty reply"); } } catch (Exception e) { m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message); } return(false); }
public LandData[] GetParcelByOwner(UUID OwnerID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["OWNERID"] = OwnerID; sendData["METHOD"] = "getparcelbyowner"; string reqString = WebUtils.BuildQueryString(sendData); List <LandData> Land = new List <LandData>(); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); foreach (object f in replyData) { KeyValuePair <string, object> value = (KeyValuePair <string, object>)f; if (value.Value is Dictionary <string, object> ) { Dictionary <string, object> valuevalue = value.Value as Dictionary <string, object>; LandData land = new LandData(); land.FromKVP(valuevalue); Land.Add(land); } } } } return(Land.ToArray()); } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString()); } return(Land.ToArray()); }
public MuteList[] GetMuteList(UUID PrincipalID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["PRINCIPALID"] = PrincipalID.ToString(); sendData["METHOD"] = "getmutelist"; string reqString = WebUtils.BuildQueryString(sendData); List <MuteList> Mutes = new List <MuteList>(); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(PrincipalID.ToString(), "RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auroradata", reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); foreach (object f in replyData) { KeyValuePair <string, object> value = (KeyValuePair <string, object>)f; if (value.Value is Dictionary <string, object> ) { Dictionary <string, object> valuevalue = value.Value as Dictionary <string, object>; MuteList mute = new MuteList(); mute.FromKVP(valuevalue); Mutes.Add(mute); } } } } return(Mutes.ToArray()); } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteMuteListConnector]: Exception when contacting server: {0}", e.ToString()); } return(Mutes.ToArray()); }
public AvatarData GetAvatar(UUID userID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); //sendData["SCOPEID"] = scopeID.ToString(); sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); sendData["METHOD"] = "getavatar"; sendData["UserID"] = userID; string reply = string.Empty; string reqString = ServerUtils.BuildQueryString(sendData); string uri = m_ServerURI + "/avatar"; // m_log.DebugFormat("[AVATAR CONNECTOR]: queryString = {0}", reqString); try { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[AVATAR CONNECTOR]: GetAgent received null or empty reply"); return(null); } } catch (Exception e) { m_log.DebugFormat("[AVATAR CONNECTOR]: Exception when contacting presence server at {0}: {1}", uri, e.Message); } Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); AvatarData avatar = null; if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) { if (replyData["result"] is Dictionary <string, object> ) { avatar = new AvatarData((Dictionary <string, object>)replyData["result"]); } } return(avatar); }
public bool StoreFriend(string PrincipalID, string Friend, int flags) { Dictionary <string, object> sendData = ToKeyValuePairs(PrincipalID, Friend, flags); sendData["METHOD"] = "storefriend"; string reply = string.Empty; try { reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/friends", ServerUtils.BuildQueryString(sendData)); } catch (Exception e) { m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: Exception when contacting friends server: {0}", e.Message); return(false); } if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null)) { bool success = false; Boolean.TryParse(replyData["Result"].ToString(), out success); return(success); } else { m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend {0} {1} received null response", PrincipalID, Friend); } } else { m_log.DebugFormat("[FRIENDS SERVICE CONNECTOR]: StoreFriend received null reply"); } return(false); }
// Helpers // private Dictionary <string, object> MakeRequest(Dictionary <string, object> sendData) { RequestsMade++; string reply = String.Empty; reply = SynchronousRestFormsRequester.MakePostRequest( m_ServerURI + "/xinventory", ServerUtils.BuildQueryString(sendData), m_Auth, m_requestTimeoutSecs); if (string.IsNullOrWhiteSpace(reply)) { return(new Dictionary <string, object>()); } Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); return(replyData); }
private Dictionary <string, object> MakeRequest(string method, Dictionary <string, object> sendData) { sendData["METHOD"] = method; string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "groups", ServerUtils.BuildQueryString(sendData), m_Auth); if (reply == string.Empty) { return(null); } Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse( reply); return(replyData); }
private bool SendAndGetBoolReply(Dictionary <string, object> sendData) { string reqString = ServerUtils.BuildQueryString(sendData); string uri = m_ServerURI + "/accounts"; // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("result")) { if (replyData["result"].ToString().ToLower() == "success") { return(true); } else { return(false); } } else { m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field"); } } else { m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply"); } } catch (Exception e) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user accounts server at {0}: {1}", uri, e.Message); } return(false); }
public EstateSettings CreateEstate(EstateSettings es, UUID RegionID) { Dictionary <string, object> sendData = es.ToKeyValuePairs(true); sendData["REGIONID"] = RegionID.ToString(); sendData["METHOD"] = "createestate"; string reqString = WebUtils.BuildXmlResponse(sendData); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData != null) { es = new EstateSettings(replyData); es.OnSave += SaveEstateSettings; return(es); } else { m_log.DebugFormat("[AuroraRemoteEstateConnector]: CreateEstate {0} received null response", RegionID); } } } } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteEstateConnector]: Exception when contacting server: {0}", e.ToString()); } return(null); }
public Byte[] MuteListRequest(UUID agentID, uint crc) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["METHOD"] = "get"; sendData["agentid"] = agentID.ToString(); sendData["mutecrc"] = crc.ToString(); try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, ServerUtils.BuildQueryString(sendData), m_Auth); if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("result")) { string datastr = replyData["result"].ToString(); if (String.IsNullOrWhiteSpace(datastr)) { return(null); } return(Convert.FromBase64String(datastr)); } else { m_log.DebugFormat("[MUTELIST CONNECTOR]: get reply data does not contain result field"); } } else { m_log.DebugFormat("[MUTELIST CONNECTOR]: get received empty reply"); } } catch (Exception e) { m_log.DebugFormat("[MUTELIST CONNECTOR]: Exception when contacting server at {0}: {1}", m_ServerURI, e.Message); } return(null); }
public uint GetFriendPerms(UUID PrincipalID, UUID friendID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["PRINCIPALID"] = PrincipalID.ToString(); sendData["FRIENDID"] = friendID.ToString(); sendData["METHOD"] = "getfriendperms"; sendData["KEY"] = m_ServiceKey; sendData["SESSIONID"] = m_SessionID.ToString(); string reqString = ServerUtils.BuildQueryString(sendData); string uri = m_ServerURI + "/hgfriends"; try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if ((replyData != null) && replyData.ContainsKey("Value") && (replyData["Value"] != null)) { uint perms = 0; uint.TryParse(replyData["Value"].ToString(), out perms); return(perms); } else { m_log.DebugFormat("[HGFRIENDS CONNECTOR]: GetFriendPerms {0} received null response", PrincipalID); } } } catch (Exception e) { m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); } return(0); }
private bool SendAndGetBoolReply(UUID avatarID, Dictionary <string, object> sendData) { string reqString = WebUtils.BuildQueryString(sendData); // MainConsole.Instance.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(avatarID.ToString(), "UserAccountServerURI"); foreach (string mServerUri in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", mServerUri + "/accounts", reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("result")) { if (replyData["result"].ToString().ToLower() == "success") { return(true); } } else { MainConsole.Instance.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount reply data does not contain result field"); } } else { MainConsole.Instance.DebugFormat("[ACCOUNTS CONNECTOR]: Set or Create UserAccount received empty reply"); } } } catch (Exception e) { MainConsole.Instance.DebugFormat("[ACCOUNTS CONNECTOR]: Exception when contacting user account server: {0}", e.Message); } return(false); }
// Helpers // private Dictionary <string, object> MakeRequest(string method, Dictionary <string, object> sendData) { sendData["METHOD"] = method; List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("InventoryServerURI"); foreach (string m_ServerURI in serverURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, WebUtils.BuildQueryString(sendData)); Dictionary <string, object> replyData = WebUtils.ParseXmlResponse( reply); return(replyData); } return(null); }
public void AddAbuseReport(AbuseReport abuse_report) { try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { Dictionary <string, object> ar = abuse_report.ToKeyValuePairs(); ar.Add("METHOD", "AddAbuseReport"); SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/abusereport", WebUtils.BuildQueryString(ar)); } } catch (Exception e) { m_log.DebugFormat("[ABUSEREPORT CONNECTOR]: Exception when contacting friends server: {0}", e.Message); } }
public Dictionary <string, object> GetExtraFeatures() { Dictionary <string, object> sendData = new Dictionary <string, object>(); Dictionary <string, object> extraFeatures = new Dictionary <string, object>(); sendData["METHOD"] = "get_grid_extra_features"; string reply = string.Empty; string uri = m_ServerURI + "/grid"; try { reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, ServerUtils.BuildQueryString(sendData), m_Auth); } catch (Exception e) { m_log.DebugFormat("[GRID CONNECTOR]: GetExtraFeatures - Exception when contacting grid server at {0}: {1}", uri, e.Message); return(extraFeatures); } if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if ((replyData != null) && replyData.Count > 0) { foreach (string key in replyData.Keys) { extraFeatures[key] = replyData[key].ToString(); } } } else { m_log.DebugFormat("[GRID CONNECTOR]: GetExtraServiceURLs received null reply"); } return(extraFeatures); }
protected bool Set(Dictionary <string, object> sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt) { sendData["UserID"] = userID; sendData["RegionID"] = regionID.ToString(); sendData["Position"] = position.ToString(); sendData["LookAt"] = lookAt.ToString(); string reqString = WebUtils.BuildQueryString(sendData); // MainConsole.Instance.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString); try { List <string> urls = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("GridUserServerURI"); foreach (string url in urls) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", url, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("result")) { if (replyData["result"].ToString().ToLower() == "success") { return(true); } else { return(false); } } } } } catch (Exception) { } return(false); }
public virtual bool DeregisterRegion(ulong regionhandle, UUID regionID, UUID SessionID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["REGIONID"] = regionID.ToString(); sendData["SESSIONID"] = SessionID.ToString(); sendData["METHOD"] = "deregister"; try { List <string> serverURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(regionhandle.ToString(), "GridServerURI"); foreach (string m_ServerURI in serverURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, WebUtils.BuildQueryString(sendData)); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success")) { return(true); } } else { m_log.DebugFormat("[GRID CONNECTOR]: DeregisterRegion received null reply"); } } } catch (Exception e) { m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); } return(false); }
private string MakeRequest(string verb, string uri, string formdata) { string reply = string.Empty; try { reply = SynchronousRestFormsRequester.MakeRequest(verb, uri, formdata, 30, m_Auth); return(reply); } catch (WebException e) { using (HttpWebResponse hwr = (HttpWebResponse)e.Response) { if (hwr != null) { if (hwr.StatusCode == HttpStatusCode.NotFound) { m_log.Error(string.Format("[ESTATE CONNECTOR]: Resource {0} not found ", uri)); return(reply); } if (hwr.StatusCode == HttpStatusCode.Unauthorized) { m_log.Error(string.Format("[ESTATE CONNECTOR]: Web request {0} requires authentication ", uri)); } } else { m_log.Error(string.Format( "[ESTATE CONNECTOR]: WebException for {0} {1} {2} {3}", verb, uri, formdata, e.Message)); } } } catch (Exception e) { m_log.DebugFormat("[ESTATE CONNECTOR]: Exception when contacting estate server at {0}: {1}", uri, e.Message); } return(null); }
public EventData GetEventInfo(string EventID) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["EVENTID"] = EventID; sendData["METHOD"] = "geteventinfo"; string reqString = WebUtils.BuildQueryString(sendData); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); foreach (object f in replyData) { KeyValuePair <string, object> value = (KeyValuePair <string, object>)f; if (value.Value is Dictionary <string, object> ) { Dictionary <string, object> valuevalue = value.Value as Dictionary <string, object>; EventData eventdata = new EventData(valuevalue); return(eventdata); } } } } } catch (Exception e) { m_log.DebugFormat("[AuroraRemoteDirectoryServiceConnector]: Exception when contacting server: {0}", e.ToString()); } return(null); }
public List <string> FindLSLData(string token, string key) { List <string> data = new List <string>(); Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["token"] = token; sendData["key"] = key; sendData["METHOD"] = "findlsldata"; string reqString = WebUtils.BuildQueryString(sendData); try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData != null) { foreach (object obj in replyData.Values) { data.Add(obj.ToString()); } } } } } catch (Exception e) { MainConsole.Instance.DebugFormat("[AuroraRemoteAssetConnector]: Exception when contacting server: {0}", e.ToString()); } return(data); }
// Helpers // private Dictionary <string, object> MakeRequest(string method, Dictionary <string, object> sendData) { // Add "METHOD" as the first key in the dictionary. This ensures that it will be // visible even when using partial logging ("debug http all 5"). Dictionary <string, object> temp = sendData; sendData = new Dictionary <string, object> { { "METHOD", method } }; foreach (KeyValuePair <string, object> kvp in temp) { sendData.Add(kvp.Key, kvp.Value); } RequestsMade++; string reply = String.Empty; int retries = 0; do { reply = SynchronousRestFormsRequester.MakeRequest( "POST", m_ServerURI + "/xinventory", ServerUtils.BuildQueryString(sendData), m_requestTimeoutSecs, m_Auth); if (reply != String.Empty) { break; } retries++; } while (retries <= m_maxRetries); Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse( reply); return(replyData); }
private UserAccount SendAndGetReply(UUID avatarID, Dictionary <string, object> sendData) { string reply = string.Empty; string reqString = WebUtils.BuildQueryString(sendData); // m_log.DebugFormat("[ACCOUNTS CONNECTOR]: queryString = {0}", reqString); UserAccount account = null; try { List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf(avatarID.ToString(), "UserAccountServerURI"); foreach (string m_ServerURI in m_ServerURIs) { reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply == null || (reply != null && reply == string.Empty)) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: GetUserAccount received null or empty reply"); return(null); } Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) { if (replyData["result"] is Dictionary <string, object> ) { account = new UserAccount((Dictionary <string, object>)replyData["result"]); return(account); } } } } catch (Exception e) { m_log.DebugFormat("[ACCOUNT CONNECTOR]: Exception when contacting user account server: {0}", e.Message); } return(account); }
public uint GetNumberOfParcelsByRegion(UUID RegionID, UUID scopeID, UUID owner, ParcelFlags flags, ParcelCategory category) { Dictionary <string, object> mess = new Dictionary <string, object>(); mess["Method"] = "GetNumberOfParcelsByRegion"; mess["RegionID"] = RegionID; mess["scopeID"] = scopeID; mess["owner"] = owner; mess["flags"] = (uint)flags; mess["category"] = (int)category; string reqString = WebUtils.BuildXmlResponse(mess); List <string> m_ServerURIs = m_registry.RequestModuleInterface <IConfigurationService>().FindValueOf("RemoteServerURI"); foreach (string m_ServerURI in m_ServerURIs) { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, reqString); if (reply != string.Empty) { Dictionary <string, object> replyData = WebUtils.ParseXmlResponse(reply); if (replyData != null) { Dictionary <string, object> .ValueCollection replyvalues = replyData.Values; uint numParcels = 0; foreach (object f in replyvalues.Where(f => uint.TryParse(f.ToString(), out numParcels))) { break; } // Success return(numParcels); } } } return(0); }
public static Dictionary <string, string> DoRequest(string url, Dictionary <string, string> postParameters) { string postData = postParameters == null ? "" : CommunicationHelpers.SerializeDictionary(postParameters); String str = String.Empty; #region // Debug #if DEBUG m_log.Debug("[OMECONOMY] Request: " + url + "?" + postData); #endif #endregion try { #if INSOMNIA ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; #endif str = SynchronousRestFormsRequester.MakeRequest("POST", url, postData, 20000); #region // Debug #if DEBUG string meth = ""; if ((postParameters != null) && !postParameters.TryGetValue("method", out meth)) { meth = ""; } m_log.DebugFormat("[OMECONOMY] Response {0}: {1}", meth, str.Trim()); #endif #endregion Dictionary <string, string> returnValue = JsonMapper.ToObject <Dictionary <string, string> >(str); return(returnValue != null ? returnValue : new Dictionary <string, string>()); } catch (Exception e) { m_log.ErrorFormat("[OMECONOMY]: Could not parse response Exception: {0} - {1}", e.Message, e.StackTrace); return(null); } }
public bool Release(UUID principalID, string token) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["PRINCIPAL"] = principalID.ToString(); sendData["TOKEN"] = token; sendData["METHOD"] = "release"; string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/auth/plain", ServerUtils.BuildQueryString(sendData), m_Auth); Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); if (replyData["Result"].ToString() != "Success") { return(false); } return(true); }
public ExperienceInfo[] GetExperienceInfos(UUID[] experiences) { Dictionary <string, object> sendData = new Dictionary <string, object>(); sendData["METHOD"] = "getexperienceinfos"; int i = 0; foreach (UUID id in experiences) { sendData[string.Format("id_{0}", i)] = id.ToString(); i++; } string request_str = ServerUtils.BuildQueryString(sendData); List <ExperienceInfo> infos = new List <ExperienceInfo>(); string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI, request_str, m_Auth); //m_log.InfoFormat("[EXPERIENCE SERVICE CONNECTOR]: Reply: {0}", reply); if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary <string, object> .ValueCollection experienceList = replyData.Values; foreach (object ex in experienceList) { if (ex is Dictionary <string, object> ) { Dictionary <string, object> experience = (Dictionary <string, object>)ex; infos.Add(new ExperienceInfo(experience)); } } } return(infos.ToArray()); }
protected bool Set(Dictionary<string, object> sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt) { sendData["UserID"] = userID; sendData["RegionID"] = regionID.ToString(); sendData["Position"] = position.ToString(); sendData["LookAt"] = lookAt.ToString(); string reqString = ServerUtils.BuildQueryString(sendData); // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString); try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "/griduser", reqString); if (reply != string.Empty) { Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); if (replyData.ContainsKey("result")) { if (replyData["result"].ToString().ToLower() == "success") return true; else return false; } else m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition reply data does not contain result field"); } else m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition received empty reply"); } catch (Exception e) { m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message); } return false; }
protected GridUserInfo Get(Dictionary <string, object> sendData) { string reqString = ServerUtils.BuildQueryString(sendData); string uri = m_ServerURI + "/griduser"; // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString); try { string reply = SynchronousRestFormsRequester.MakeRequest("POST", uri, reqString, m_Auth); if (reply != string.Empty) { Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse(reply); GridUserInfo guinfo = null; if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null)) { if (replyData["result"] is Dictionary <string, object> ) { guinfo = Create((Dictionary <string, object>)replyData["result"]); } } return(guinfo); } else { m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply"); } } catch (Exception e) { m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server at {0}: {1}", uri, e.Message); } return(null); }
// // // // // #region Make Request private Dictionary <string, object> MakeRequest(string method, Dictionary <string, object> sendData) { sendData["METHOD"] = method; string reply = string.Empty; reply = SynchronousRestFormsRequester.MakeRequest("POST", m_ServerURI + "hg-groups", ServerUtils.BuildQueryString(sendData)); //m_log.DebugFormat("[XXX]: reply was {0}", reply); if (string.IsNullOrEmpty(reply)) { return(null); } Dictionary <string, object> replyData = ServerUtils.ParseXmlResponse( reply); return(replyData); }