public void SetText( JSON json ) { AddHeader( "Content-Type", "application/json" ); SetText( json.Data ); }
public static void JoinWorld( int worldId, string playerClass ) { if( worldId < 0 ) { throw new ArgumentException( string.Format("WorldId( {0} ) is invalid", worldId) ); } HTTP.JSON playerT = new HTTP.JSON( "{ \"player\": {\"type\": \"" + playerClass + "\"}}" ); //WWW www = WWWX.Post( string.Format("{0}/worlds/{1}/players.json", urlServer, worldId), playerT, authenticatedGodModeParameters ); HTTP.Request request = new HTTP.Request( "Post", string.Format("{0}/worlds/{1}/players.json", urlServer, worldId) ); request.SetText( playerT ); request.AddParameters( authenticatedGodModeParameters ); request.Send(); while( !request.isDone ) { } Debug.Log(request.response.Text); request = new HTTP.Request( "Get", urlGetUserPlayers() ); request.AddParameters( authenticatedGodModeParameters ); request.Send(); while( !request.isDone ) { } }
/// <summary> /// Gets a WWW object do perform the harvest, configured for the associated api point on the server. /// </summary> /// <returns> /// The do it WWW. /// </returns> public HTTP.Request GetDoItWWW() { string apiPoint = ""; Dictionary<string, string> parameters = WebRequests.authenticatedParameters; switch (this.cutType) { case CutType.Clearcut: apiPoint = "clearcut"; break; case CutType.DiameterLimitCut: apiPoint = "diameter_limit_cut"; parameters.Add(this.diameterLimitCutDirection==DiameterLimitCutDirection.Greater?"above":"below", this.diameterLimit.ToString()); break; case CutType.QRatioCut: apiPoint = "partial_selection_cut"; parameters.Add("qratio", this.qRatio.ToString()); parameters.Add("target_basal_area", this.basalArea.ToString()); break; } string url = string.Format( "{0}/worlds/{1}/resource_tiles/{2}.json", WebRequests.urlServer, UserData.worldNumber, apiPoint ); HTTP.Request request = new HTTP.Request( "Post", url ); request.AddParameters( parameters ); HTTP.JSON json = new HTTP.JSON(); json.Data = JsonMapper.ToJson( new ResourceTileSelection(this.ids) ); request.SetText(json); ///.ToJson() ); //Debug.Log(new ResourceTileSelection(this.ids).ToJson()); return request; }