/// <summary> /// Query if this object issue request 2. /// </summary> /// /// <param name="host"> The host. </param> /// <param name="path"> Full pathname of the file. </param> /// <param name="headers"> The headers. </param> /// <param name="method"> (Optional) The method. </param> /// <param name="body"> (Optional) The body. </param> /// <param name="secure"> (Optional) true to secure. </param> /// <param name="port"> (Optional) The port. </param> /// /// <returns> /// true if it succeeds, false if it fails. /// </returns> internal RequestResponse IssueRequest( string host, string path, Dictionary <string, string> headers, string method = "GET", string body = "", Boolean secure = false, Int32 port = 80) { IWebServiceRequest ds = getInterface <IWebServiceRequest>(); RequestResponse response = new RequestResponse(); if (ds != null) { ds.WebServiceRequest( new RequestSetttings { method = method, uri = new Uri(string.Format("http{0}://{1}{2}/{3}", secure ? "s" : String.Empty, host, port == 80 ? String.Empty : String.Format(":{0}", port), path.TrimStart('/') )), requestHeaders = headers, //! allowedResponsCodes, // TODO default is ok body = body, // or method.Equals("GET")?string.Empty:body }, out response); } return(response); }
/// <summary> /// Method loading domain model - location specified by settings. /// </summary> /// <returns>Domain Model for the player.</returns> internal DomainModel loadDefaultDomainModel() { loggingDM("Loading default Domain model."); DomainModelAssetSettings dmas = (DomainModelAssetSettings)getDMA().Settings; if (dmas.LocalSource) { IDataStorage ids = DomainModelAsset.Instance.getInterfaceFromAsset <IDataStorage>(); if (ids != null) { if (!ids.Exists(dmas.Source)) { loggingDM("File " + dmas.Source + " not found for loading Domain model.", Severity.Error); //throw new Exception("EXCEPTION: File "+ dmas.Source + " not found for loading Domain model.") ; return(null); } loggingDM("Loading DomainModel from File."); return(this.getDMFromXmlString(ids.Load(dmas.Source))); } else { loggingDM("IDataStorage bridge absent for requested local loading method of the Domain model.", Severity.Error); //throw new Exception("EXCEPTION: IDataStorage bridge absent for requested local loading method of the Domain model."); return(null); } } else { IWebServiceRequest iwr = DomainModelAsset.Instance.getInterfaceFromAsset <IWebServiceRequest>(); if (iwr != null) { loggingDM("Loading web DomainModel."); Uri uri = new Uri(dmas.Source); Dictionary <string, string> headers = new Dictionary <string, string>(); //headers.Add("user", playerId); //string body = dmas.Source; WebServiceResponse wsr = new WebServiceResponse(); //currentPlayerId = playerId; RequestSetttings rs = new RequestSetttings(); rs.method = "GET"; rs.uri = uri; rs.requestHeaders = headers; //rs.body = body; RequestResponse rr = new RequestResponse(); iwr.WebServiceRequest(rs, out rr); return(this.getDMFromXmlString(rr.body)); } else { loggingDM("IWebServiceRequest bridge absent for requested web loading method of the Domain model.", Severity.Error); // new Exception("EXCEPTION: IWebServiceRequest bridge absent for requested web loading method of the Domain model."); return(null); } } }
/// <summary> /// Query if this object issue request 2. /// </summary> /// /// <param name="method"> The method. </param> /// <param name="uri"> URI of the document. </param> /// <param name="headers"> The headers. </param> /// <param name="body"> (Optional) The body. </param> /// /// <returns> /// A RequestResponse. /// </returns> internal RequestResponse IssueRequest(string method, Uri uri, Dictionary <string, string> headers, string body = "") { IWebServiceRequest ds = getInterface <IWebServiceRequest>(); RequestResponse response = new RequestResponse(); if (ds != null) { ds.WebServiceRequest( new RequestSetttings { method = method, uri = uri, requestHeaders = headers, //! allowedResponsCodes, // TODO default is ok body = body, }, out response); } return(response); }