public void SendData(JSONObject obj) { print("<color=#32D51CFF>SEND :</color> " + obj.Print()); JSONObject newData = new JSONObject(); string tempstr = AESEncrypt(obj.Print(), ENCKEY, ENCIV); newData.AddField("data", tempstr); socket.Emit("req", newData); }
internal void SendMessage(JSONObject jdata, string en) { JSONObject data = new JSONObject(); // = new JSONObject("{ \"type\": \"login\", \"data\":{ \"email\": $user_email, \"password\": $user_password, \"lat\": $latitude, \"lng\": $longitude }}"); data.AddField("type", en); data.AddField("data", jdata); w.Send(data.Print()); print("Send Data To Server " + data.Print()); }
public static async Task <RequestJSONResult> GetWebJSONAsync(string url, JSONObject requestinfo) { RequestJSONResult loadresult = new RequestJSONResult(); try { using (HttpRequestMessage requestmessage = new HttpRequestMessage(HttpMethod.Post, url)) { requestmessage.Version = new Version(1, 1); string requestcontent = requestinfo.Print(true); requestmessage.Content = new StringContent(requestcontent, Encoding.UTF8, "application/json"); using (HttpResponseMessage responsemessage = await httpClient.SendAsync(requestmessage)) { loadresult.Status = responsemessage.StatusCode; loadresult.IsSuccess = responsemessage.IsSuccessStatusCode; if (responsemessage.IsSuccessStatusCode) { string content = await responsemessage.Content.ReadAsStringAsync(); loadresult.Object = new JSONObject(content); } } } } catch (Exception e) { loadresult.IsException = true; loadresult.ThrownException = e; } return(loadresult); }
//Recording human data for training public string SerializeList() { _serializedObject = new JSONObject(JSONObject.Type.OBJECT); JSONObject data = new JSONObject(JSONObject.Type.ARRAY); foreach (Values v in informationList) { JSONObject trainingCase = new JSONObject(JSONObject.Type.OBJECT); //trainingCase.AddField("normalizedSpeed", MoveCar.normalizedSpeed); trainingCase.AddField("scaledForward", v.sentScaledForward); trainingCase.AddField("scaledLeftRightRatio", v.sentScaledLRRatio); trainingCase.AddField("isAccelerating", v.isAccelerating); trainingCase.AddField("scaledSpeed", v.sentScaledSpeed); trainingCase.AddField("isTurningLeft", v.isTurningLeft); trainingCase.AddField("isTurningRight", v.isTurningRight); trainingCase.AddField("isKeepingStraight", v.isNotTurning); data.Add(trainingCase); //Debug.Log("New Training Case: " + trainingCase.Print()); } _serializedObject.AddField("data", data); JSONObject types = new JSONObject(JSONObject.Type.ARRAY); types.Add("motion"); types.Add("steering"); _serializedObject.AddField("types", types); return(_serializedObject.Print()); }
public KnetikApiResponse ListStorePage( int page = 1, int limit = 10, List<string> terms = null, List<string> related = null, bool useCatalog = true, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("page", page); j.AddField ("limit", limit); if (terms != null) { j.AddField ("terms", JSONObject.Create(terms)); } if (related != null) { j.AddField ("related", JSONObject.Create(related)); } j.AddField("useCatalog", useCatalog); String body = j.Print (); KnetikRequest req = CreateRequest(ListStorePageEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public void DoPostRequest(string method, JSONObject param, System.Action <JSONNode> callback) { StartCoroutine(PostRequest("https://" + ipadd + method, param.Print(), returnValue => { callback(JSON.Parse(returnValue)); })); }
static void UpdatePlayerData(JSONObject playerObject, string key) { if (IsPlayerJSONValid(playerObject) && !String.IsNullOrEmpty(key)) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(SERVER_URL + SERVER_TABLE_NAME + String.Format("/{0}.json?auth={1}", key, SERVER_AUTH)); request.Method = "PATCH"; using (StreamWriter writer = new StreamWriter(request.GetRequestStream())) { writer.Write(playerObject.Print()); } var response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode != HttpStatusCode.OK) { StringBuilder builder = new StringBuilder(); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { builder.AppendFormat("Cannot update player {0}'s data:", playerObject[FIELD_NAME].ToString()); builder.AppendLine(); builder.Append(reader.ReadToEnd()); } throw new WebException(builder.ToString()); } } }
public static void ProcessBoughtPromotionResponse(SpilPromotionData boughtPromotion) { SpilPromotionData promotion = null; foreach (SpilPromotionData promotionData in PromotionData) { if (promotionData.id == boughtPromotion.id) { promotionData.amountPurchased = boughtPromotion.amountPurchased; promotion = promotionData; break; } } bool maxReached = false; if (promotion != null && (promotion.amountPurchased == promotion.maxPurchase || promotion.amountPurchased > promotion.maxPurchase)) { PromotionData.Remove(promotion); maxReached = true; } JSONObject data = new JSONObject(); data.AddField("promotionId", boughtPromotion.id); data.AddField("amountPurchased", boughtPromotion.amountPurchased); data.AddField("maxAmountReached", maxReached); SpilUnityImplementationBase.firePromotionAmountBought(data.Print()); }
public static void Serialize(this Template template) { // Template var tplJs = new JSONObject(JSONObject.Type.OBJECT); // Operators var opsJs = new JSONObject(JSONObject.Type.ARRAY); tplJs.AddField("Operators", opsJs); foreach (KeyValuePair<string, Operator> kvp in template.Operators) { opsJs.Add(kvp.Value.Serialize()); } // Connections var connsJs = new JSONObject(JSONObject.Type.ARRAY); tplJs.AddField("Connections", connsJs); foreach (IOConnection conn in template.Connections) { connsJs.Add(conn.Serialize()); } template.JSON = tplJs.Print(true); #if UNITY_EDITOR EditorUtility.SetDirty(template); #endif }
/// <summary> /// Exports the geographic data in packed string format. /// </summary> public string GetMountPointsGeoData() { JSONObject json = new JSONObject(); for (int k = 0; k < mountPoints.Count; k++) { MountPoint mp = mountPoints[k]; JSONObject mpJSON = new JSONObject(); mpJSON.AddField("Name", DataEscape(mp.name)); int provinceUniqueID = -1; if (mp.provinceIndex >= 0 && mp.provinceIndex < provinces.Length) { provinceUniqueID = provinces[mp.provinceIndex].uniqueId; } mpJSON.AddField("Province", provinceUniqueID); int countryUniqueID = -1; if (mp.countryIndex >= 0 && mp.countryIndex < countries.Length) { countryUniqueID = countries[mp.countryIndex].uniqueId; } mpJSON.AddField("Country", countryUniqueID); mpJSON.AddField("Type", mp.type); mpJSON.AddField("X", mp.unity2DLocation.x); mpJSON.AddField("Y", mp.unity2DLocation.y); mpJSON.AddField("Id", mp.uniqueId); mpJSON.AddField("Attrib", mp.attrib); json.Add(mpJSON); } return(json.Print(true)); }
private IEnumerator envia_tiempo_objetos(JSONObject j) { yield return(new WaitForEndOfFrame()); WWWForm form = new WWWForm(); form.AddField("json", j.Print()); WWW link = new WWW("http://monitorizer.sytes.net:8000/polls/add_session/", form); yield return(link); if (!string.IsNullOrEmpty(link.error)) { print(link.error); enviado = true; } else { enviado = true; print("Finished Uploading Info"); } }
public static void postDropDisk(int column, bool endTurn) { JSONObject j = new JSONObject(); j.AddField("dropDisk", column); postMove(j.Print(), endTurn); }
public override void UserPlayAsGuest() { SpilEvent spilEvent = Spil.MonoInstance.gameObject.AddComponent <SpilEvent>(); spilEvent.eventName = "userPlayAsGuest"; string newUid = Guid.NewGuid().ToString(); spilEvent.customData.AddField("newUid", newUid); spilEvent.Send(); Spil.SpilUserIdEditor = newUid; unauthorized = false; spilToken = null; JSONObject loginResponse = new JSONObject(); loginResponse.AddField("resetData", true); loginResponse.AddField("socialProvider", (string)null); loginResponse.AddField("socialId", (string)null); loginResponse.AddField("isGuest", true); SpilUnityImplementationBase.fireLoginSuccessful(loginResponse.Print()); }
public KnetikApiResponse CustomLogin( string serviceEndpoint, string usernameOrEmail, string password, bool isEmail, Action<KnetikApiResponse> cb = null ) { JSONObject json = new JSONObject (JSONObject.Type.OBJECT); if (isEmail) { json.AddField("email", usernameOrEmail); } else { json.AddField("username", usernameOrEmail); } json.AddField("password", password); json.AddField ("serial", KnetikApiUtil.getDeviceSerial()); json.AddField ("mac_address", KnetikApiUtil.getMacAddress ()); // Device Type is currently limited to 3 characters in the DB json.AddField ("device_type", KnetikApiUtil.getDeviceType()); json.AddField ("signature", KnetikApiUtil.getDeviceSignature()); string body = json.Print (); KnetikRequest req = CreateRequest(serviceEndpoint, body, "POST", -1, ""); KnetikApiResponse res = new KnetikLoginResponse(this, req, cb); return res; }
/* * InitSession * Inicia la sesión del juego y obtiene un identificador de sesión. * Se utiliza para almacenar la profesión y agrupar el progreso por fecha. */ private static string InitSession(string profession) { JSONObject sessionData = new JSONObject(JSONObject.Type.OBJECT); sessionData.AddField("fecha", System.DateTime.Now.ToString()); sessionData.AddField("profesion", profession); //Consulta HTTPS POST string response = DoRequest(url + "sesiones/" + user + ".json", "POST", sessionData.Print()); if (response == "ERROR") { Debug.Log("Error InitSession"); return(""); } else { Debug.Log("InitSession Done"); JSONObject json = new JSONObject(response); string sessionId = ((JSONObject)json.GetField("name")).str; Request.sessionId = sessionId; Debug.Log(sessionId); return(sessionId); } }
/* * Gets data from http request * Afterwards, completes action (function) */ public IEnumerator getData(string query, Action action = null) { UnityWebRequest request; if (query.Length > 0) { request = new UnityWebRequest(siteURL + "/_functions-dev/" + functionName + "?" + query); } else { request = new UnityWebRequest(siteURL + "/_functions-dev/" + functionName); } request.downloadHandler = new DownloadHandlerBuffer(); yield return(request.SendWebRequest()); if (request.isNetworkError || request.isHttpError) { Debug.Log(request.error); } else { json = JSONObject.Create(request.downloadHandler.text); Debug.Log(json.Print(true)); } if (action != null) { action(); } }
public string encodeBoard(bool board = true, bool sendPMoves = false, bool evaluated = false) { JSONObject jBoard = new JSONObject(); if (board) { jBoard.AddField(Consts.Fields.board, grid); } if (evaluated) { jBoard.AddField(Consts.Fields.boardState, boardState.ToString()); } if (sendPMoves) { if (possibleMoves.Count == 0) { List <JSONObject> list = new List <JSONObject>(); // Ugly fix for sending empty list instead of "null" jBoard.AddField(Consts.Fields.possibleMoves, new JSONObject(list.ToArray())); } else { JSONObject list = new JSONObject(); foreach (int i in possibleMoves) { list.Add(i); } jBoard.AddField(Consts.Fields.possibleMoves, list); } } return(jBoard.Print()); }
protected override void DataParser(JSONObject jsonObject) { int code = API_Helper.GetCode(jsonObject); string message = API_Helper.GetMessage(jsonObject); JSONObject result = null; if (API_Code.CodeIsNoContentUpdated(code)) { var localSaveJson = new JSONObject(localSaveJsonString); result = API_Helper.GetResult(localSaveJson); } else if (jsonObject.HasField("result")) { result = API_Helper.GetResult(jsonObject); if (API_Code.CodeIsNormalSuccess(code)) { var fileStream = File.CreateText(filePath); fileStream.Write(jsonObject.Print()); fileStream.Close(); } } OnRequestDataSuccess(code, message, result); }
public static void Serialize(this Template template) { // Template var tplJs = new JSONObject(JSONObject.Type.OBJECT); // Operators var opsJs = new JSONObject(JSONObject.Type.ARRAY); tplJs.AddField("Operators", opsJs); foreach (KeyValuePair <string, Operator> kvp in template.Operators) { opsJs.Add(kvp.Value.Serialize()); } // Connections var connsJs = new JSONObject(JSONObject.Type.ARRAY); tplJs.AddField("Connections", connsJs); foreach (IOConnection conn in template.Connections) { connsJs.Add(conn.Serialize()); } template.JSON = tplJs.Print(true); #if UNITY_EDITOR EditorUtility.SetDirty(template); #endif }
static void ExportActiveScene() { string targetpath = EditorUtility.SaveFilePanel("Save json file to", "", "test", "json"); if (targetpath.Length != 0) { FileStream filestream = File.Open(targetpath, FileMode.Create); StreamWriter jsonfile = new StreamWriter(filestream); Scene scene = SceneManager.GetActiveScene(); JSONObject rootobj = JSONObject.obj; int root_count = scene.rootCount; GameObject[] goArray = scene.GetRootGameObjects(); for (int i = 0; i < root_count; ++i) { GameObject go = goArray [i]; ToJsonGameObject.ExportGameObject(rootobj, go); } jsonfile.Write(rootobj.Print(true)); jsonfile.Close(); filestream.Close(); } }
private void OnReceiveMessage(SocketIOEvent evt) { JSONObject obj = evt.data.list[0]; string msg = obj.Print().Replace("\"", ""); chatManager.ReceiveMessage(msg); }
public void saveWorldMapThread() { if (!Directory.Exists("Assets/Resources/Saves/" + temporarySaveDirectory + "/Maps/")) { Directory.CreateDirectory("Assets/Resources/Saves/" + temporarySaveDirectory + "/Maps"); } foreach (Region r in regions) { using (StreamWriter writer = new StreamWriter("Assets/Resources/Saves/" + temporarySaveDirectory + "/Maps/Region_" + r.CapitolIndex + ".tiles")) { JSONObject map = new JSONObject(JSONObject.Type.ARRAY); for (int x = 0; x < r.Map.GetLength(0); x++) { JSONObject row = new JSONObject(JSONObject.Type.OBJECT); row.AddField("x", x); JSONObject column = new JSONObject(JSONObject.Type.ARRAY); for (int y = 0; y < r.Map.GetLength(0); y++) { column.Add(r.Map[x, y].ToString()); } row.AddField("rowvalues", column); map.Add(row); } writer.Write(EncryptDecrypt(map.Print(true))); } } }
//Creates a JSON from a resultModel and parses it to the POSTFacade public void ParseToJsonResult(ResultModel resultModel, string command) { JSONObject json = new JSONObject (JSONObject.Type.OBJECT); json.AddField("UserID", resultModel.UserID); json.AddField("UserType", resultModel.UserType); JSONObject arr = new JSONObject(JSONObject.Type.ARRAY); json.AddField("Answers",arr); foreach(QuizOptionModel qm in resultModel.Options){ JSONObject ans = new JSONObject(JSONObject.Type.OBJECT); ans.AddField("ID",qm.Id); ans.AddField("Title",qm.Title); ans.AddField("Selected",qm.Selected); arr.Add(ans); } switch(command){ case "SaveToServer": POSTFacade facade = gameObject.GetComponent<POSTFacade> (); facade.SaveQuizAnswers (json,resultModel.UserID.ToString()); break; case "SaveLocal": PlayerPrefs.SetString("TestToSave_"+resultModel.UserID, json.Print()); break; } }
internal void SendMessage(string en) { JSONObject data = new JSONObject(); data.AddField("type", en); w.Send(data.Print()); }
private static void addAdDealsSDKWithJson(string projectJson) { if (!System.IO.File.Exists(projectJson)) { Debug.Log("ERROR! Project nuget json not exist:" + projectJson); return; } string jsonString = System.IO.File.ReadAllText(projectJson); JSONObject j = new JSONObject(jsonString); JSONObject dep = j.GetField("dependencies"); if (null != dep && dep.HasField("AdDealsUniversalSDKW81")) { return; } if (null == dep) { dep = new JSONObject(); j.AddField("dependencies", dep); } dep.AddField("AdDealsUniversalSDKW81", "4.6.0"); string newJsonString = j.Print(true); System.IO.File.WriteAllText(projectJson, newJsonString); }
public static void Do() { // 生成version.json int version = (_main << 24) | (_mid << 16) | (_min << 8) | (_build & 0xff); JSONObject root = new JSONObject(JSONObject.Type.OBJECT); root.AddField("version", version); JSONObject abs = new JSONObject(JSONObject.Type.OBJECT); root.AddField("abs", abs); #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN DirectoryInfo streaming = new DirectoryInfo(Application.streamingAssetsPath + "/Win64"); #elif UNITY_IOS DirectoryInfo streaming = new DirectoryInfo(Application.streamingAssetsPath + "/iOS"); #elif UNITY_ANDROID DirectoryInfo streaming = new DirectoryInfo(Application.streamingAssetsPath + "/Android"); #endif XX(abs, string.Empty, streaming); string en = root.Print(); FileStream fs = new FileStream(GetVersionPath() + "/version.json", FileMode.OpenOrCreate, FileAccess.ReadWrite); StreamWriter sw = new StreamWriter(fs); sw.Write(en); sw.Close(); fs.Close(); }
public static string encodeBoardState(string boardState) { JSONObject jObj = new JSONObject(); jObj.AddField(Constants.Fields.boardState, boardState); return(jObj.Print()); }
/// <summary> /// 세션 저장 /// </summary> /// <param name="session"></param> /// <param name="filepath"></param> public static void Save(FSNSession session, string filepath, string saveTitle = "") { { var json = new JSONObject(JSONObject.Type.OBJECT); // Script 관련 json.AddField(c_field_scriptName, session.ScriptName); json.AddField(c_field_scriptHash, session.ScriptHashKey); json.AddField(c_field_snapshotIndex, session.SnapshotIndex); // 세이브 정보 json.AddField(c_field_saveDateTime, FSNUtils.GenerateCurrentDateAndTimeString()); json.AddField(c_field_saveTitle, saveTitle); // 플래그 테이블 var flagtable = new JSONObject(JSONObject.Type.OBJECT); json.AddField(c_field_flagTable, flagtable); foreach (var pair in session.m_flagTable) { flagtable.AddField(pair.Key, pair.Value); } // 값 테이블 var valuetable = new JSONObject(JSONObject.Type.OBJECT); json.AddField(c_field_valueTable, valuetable); foreach (var pair in session.m_valueTable) { valuetable.AddField(pair.Key, pair.Value); } FSNUtils.SaveTextData(filepath, json.Print()); } }
public KnetikApiResponse Register( string username, string password, string email, string fullname, Action<KnetikApiResponse> cb = null ) { // Login as a guest KnetikApiResponse loginResponse = GuestLogin (); if (loginResponse.Status != KnetikApiResponse.StatusType.Success) { Debug.LogError("Guest login failed"); return loginResponse; } Debug.Log ("Guest login successful"); // Then register the new user JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("username", username); j.AddField ("password", password); j.AddField ("email", email); j.AddField ("fullname", fullname); String body = j.Print (); KnetikRequest req = CreateRequest(RegisterEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
public string Serialize() { JSONObject jsonObject = new JSONObject(); jsonObject.AddField("clientId", ClientId); jsonObject.AddField("direction", Direction); return(jsonObject.Print()); }
// Token: 0x0600001E RID: 30 RVA: 0x00004178 File Offset: 0x00002378 public static void saveData(JSONObject node) { string value = node.Print(true); StreamWriter streamWriter = new StreamWriter(new FileStream(LayaTerrainExporter.m_saveLocation + "/" + LayaTerrainExporter.m_terrain.name.ToLower() + ".lt", FileMode.Create, FileAccess.Write)); streamWriter.Write(value); streamWriter.Close(); }
/// <summary> /// Persistent 데이터 세이브 /// </summary> public static void Save(bool force = false) { if (IsDirty || force) // 변경점이 있을 때만 저장, force가 올라가있다면 무조건 { FSNUtils.SaveTextData(c_persistent_filename, m_persData.Print()); IsDirty = false; // dirty 플래그 내리기 } }
public static void saveData(JSONObject node) { string str = node.Print(true); StreamWriter writer1 = new StreamWriter(new FileStream(m_saveLocation + "/" + m_terrain.get_name().ToLower() + ".lt", System.IO.FileMode.Create, FileAccess.Write)); writer1.Write(str); writer1.Close(); }
public static void postSpecial(int specialId, int id, bool endTurn) { JSONObject j = new JSONObject(); j.AddField("special", specialId); j.AddField("id", id); postMove(j.Print(), endTurn); }
private string GetPongMessage() { JSONObject message = new JSONObject(JSONObject.Type.OBJECT); message.AddField(Field.MSG, MessageType.PONG); return(message.Print()); }
public void SaveLevel( Level level ) { JSONObject root = new JSONObject(JSONObject.Type.OBJECT); level.Save(root); string filePath = Application.dataPath + "/Resources/level_" + level.Number + ".json"; File.WriteAllBytes(filePath, System.Text.Encoding.UTF8.GetBytes (root.Print(true))); }
public KnetikApiResponse Register( string username, string password, string email, string fullname, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("username", username); j.AddField ("password", password); j.AddField ("email", email); j.AddField ("fullname", fullname); String body = j.Print (); KnetikRequest req = CreateRequest(RegisterEndpoint, body); KnetikApiResponse res; if(cb != null) { res = new KnetikApiResponse(this, req, (resp) => { Debug.Log(resp.Body); if(resp.Status == KnetikApiResponse.StatusType.Success) { Login(username, password, cb); } else { if (OnRegisterFailed != null) { OnRegisterFailed(resp.ErrorMessage); } } cb(resp); }); } else { res = new KnetikApiResponse(this, req, null); Debug.Log(res.Body); if(res.Status == KnetikApiResponse.StatusType.Success) { Debug.Log(res.Body); res = Login(username, password, null); } else { if (OnRegisterFailed != null) { OnRegisterFailed(res.ErrorMessage); } } } return res; }
public KnetikApiResponse entitlementCheck(JSONObject j,Action<KnetikApiResponse> cb = null ) { String body = j.Print (); KnetikRequest req = CreateRequest(EntitlementEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse verifyGooglePayment(JSONObject j,Action<KnetikApiResponse> cb = null ) { String body = j.Print (); KnetikRequest req = CreateRequest(GooglePaymentEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
private static void ShowSplashScreen(JSONObject data, string url) { Debug.Log("Opening URL: " + url + " With data: " + data.Print(false)); SpilUnityEditorImplementation.fireSplashScreenOpen(); GameObject overlayObject = GameObject.CreatePrimitive (PrimitiveType.Cube); WebOverlay overlay = overlayObject.AddComponent<WebOverlay> (); overlay.overlayType = "splashScreen"; }
public KnetikApiResponse GetUserInfoWithProduct(string productIdentifier, Action<KnetikApiResponse> cb = null) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("productId", productIdentifier); String body = j.Print (); KnetikRequest req = CreateRequest(GetUserInfoWithProductEndpoint, body); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public WWW SaveQuizAnswers(JSONObject json, string UserID) { needToSendJSON = json; byte [] bytes = Encoding.ASCII.GetBytes(json.Print()); string serverFunction = "SaveQuizAnswers"; callMethod = "POSTAnswers"; www = new WWW (baseUrl+serverFunction, bytes,CreateHeader()); StartCoroutine (WaitForRequest (www, UserID)); return www; }
public KnetikApiResponse PutUserInfo(string name, string value, Action<KnetikApiResponse> cb = null) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("configName", name); j.AddField ("configValue", value); String body = j.Print (); KnetikRequest req = CreateRequest(PutUserInfoEndpoint, body); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse GetRelationships(int ancestorDepth, int descendantDepth, bool includeSiblings, Action<KnetikApiResponse> cb = null) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("ancestorDepth", ancestorDepth); j.AddField ("descendantDepth", descendantDepth); j.AddField ("includeSiblings", includeSiblings); String body = j.Print (); KnetikRequest req = CreateRequest(UserGetRelationshipsEndpoint, body); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse CartCountries( Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); String body = j.Print (); KnetikRequest req = CreateRequest(CartCountriesEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse GuestRegister( Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); String body = j.Print (); KnetikRequest req = CreateRequest(GuestRegisterEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }
public KnetikApiResponse UseItem( int itemID, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("item_id", itemID); String body = j.Print (); KnetikRequest req = CreateRequest(UseItemEndpoint, body); return new KnetikApiResponse(this, req, cb); }
public KnetikApiResponse CustomCall( string serviceEndpoint, Dictionary<string, string> parameters, Action<KnetikApiResponse> cb = null ) { JSONObject json = new JSONObject(parameters); string body = json.Print(); KnetikRequest req = CreateRequest(serviceEndpoint, body, "POST", -1, ""); KnetikApiResponse res = new KnetikApiResponse(this, req, cb); return res; }
public KnetikApiResponse CartAddDiscount( string sku, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("sku", sku); String body = j.Print (); KnetikRequest req = CreateRequest(CartAddDiscountEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
//Server sending server data to 3d environment public string GetDistanceToObject() { _serializedObject = new JSONObject (JSONObject.Type.OBJECT); JSONObject trainingCase = new JSONObject(JSONObject.Type.OBJECT); trainingCase.AddField("scaledSpeed", MoveCar.scaledSpeed); trainingCase.AddField("scaledForward", scaledForward); trainingCase.AddField("scaledLeftRightRatio", scaledLRRatio); _serializedObject.AddField("data", trainingCase); JSONObject types = new JSONObject(JSONObject.Type.ARRAY); types.Add ("motion"); types.Add ("steering"); _serializedObject.AddField("types", types); return _serializedObject.Print (); }
public KnetikApiResponse FireEvent( string eventName, Dictionary<string, string> parameters, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("eventName", eventName); j.AddField ("params", JSONObject.Create(parameters)); String body = j.Print (); KnetikRequest req = CreateRequest(FireEventEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse GetGameOption( int gameId, string optionName, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("productId", gameId); j.AddField ("optionName", optionName); String body = j.Print (); KnetikRequest req = CreateRequest(GetGameOptionEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
static string jsonify(GameObject[] gameObjects,int[] intervals) { JSONObject json = new JSONObject (JSONObject.Type.OBJECT); JSONObject jenemies = new JSONObject (JSONObject.Type.ARRAY); json.AddField ("enemies",jenemies); foreach(GameObject go in gameObjects) jenemies.Add (go); JSONObject jintervals = new JSONObject (JSONObject.Type.ARRAY); json.AddField ("intervals",jintervals); foreach(int i in intervals) jintervals.Add (i); return json.Print (); }
public KnetikApiResponse ListUserAchievements( int page = 1, int perPage = 25, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("page_index", page); j.AddField ("page_size", perPage); String body = j.Print (); KnetikRequest req = CreateRequest(ListUserAchievementsEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
/*JSAPI2 Function Add Item to A Cart @params int catalogId @params int catalogSkuId @params int quantity @params Action<KnetikApiResponse> cb */ public KnetikApiResponse CartAdd(string cartNumber,int catalogId, int catalogSkuId, int quantity, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("catalog_id", catalogId); j.AddField ("catalog_sku_id", catalogSkuId); j.AddField ("quantity", quantity); String body = j.Print (); StringBuilder CartItemsEndpointBuilder = new StringBuilder(); CartItemsEndpointBuilder.AppendFormat(CartItemsEndpoint,cartNumber); KnetikRequest req = CreateRequest(CartItemsEndpointBuilder.ToString(), body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
public KnetikApiResponse CartAdd( int catalogId, int catalogSkuId, int quantity, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("catalog_id", catalogId); j.AddField ("catalog_sku_id", catalogSkuId); j.AddField ("quantity", quantity); String body = j.Print (); KnetikRequest req = CreateRequest(CartAddEndpoint, body); KnetikApiResponse response = new KnetikApiResponse(this, req, cb); return response; }
void TestEscapeSpecials() { foreach (KeyValuePair<string, string> keys in testCases) { string key = keys.Key; Debug.Log ("TEST [Form JSON]: " + key); JSONObject obj = new JSONObject(); obj.AddField(key, testCases[key]); AssertStrEqual(testCases[key], obj[key].str, "storage of value"); string simpleJSON = SimpleJSONConstructor(key, testCases[key]); AssertStrEqual(simpleJSON, testCasesJSONRepresentation[key], "simpleJSON match correct JSON"); string stringRepresentation = obj.ToString(); string printRepresentation = obj.Print(); bool createJSONCorrectly = AssertStrEqual(simpleJSON, stringRepresentation, "match ToString() to correct JSON"); AssertStrEqual(simpleJSON, printRepresentation, "match Print() to correct JSON"); Debug.Log ("TEST [Reform JSON]: " + key); try { Debug.Log("string representation: " + stringRepresentation); JSONObject resultObj = new JSONObject(stringRepresentation); Debug.Log("from constructor: " + resultObj.ToString()); AssertStrEqual(resultObj.ToString(), simpleJSON, "result from JSONObject constructor using ToString() result"); AssertStrEqual(resultObj[key].str, testCases[key]); } catch (Exception e){ Debug.LogError("Problem reforming json. " + e.ToString()); } Debug.Log ("TEST [Reform JSON using result from SimpleJSONConstructor]: " + key); try { JSONObject resultObj = new JSONObject(simpleJSON); AssertStrEqual(resultObj.ToString(), simpleJSON, "result from JSONObject constructor using correct JSON"); AssertStrEqual(resultObj[key].str, testCases[key]); } catch (Exception e){ Debug.LogError("Problem reforming json using correct JSON: " + simpleJSON + " " + e.ToString()); } Debug.Log ("******"); } }
public KnetikApiResponse Login( string username, string password, Action<KnetikApiResponse> cb = null ) { int timestamp = GetTimestamp (); string endpoint; string body; string serviceBundle = null; JSONObject json = new JSONObject (JSONObject.Type.OBJECT); json.AddField ("serial", KnetikApiUtil.getDeviceSerial()); json.AddField ("mac_address", KnetikApiUtil.getMacAddress ()); // Device Type is currently limited to 3 characters in the DB json.AddField ("device_type", KnetikApiUtil.getDeviceType()); json.AddField ("signature", KnetikApiUtil.getDeviceSignature()); if (Authentication == null || Authentication == "" || Authentication == "default") { endpoint = SessionEndpoint; Username = username; Password = EncodePassword(password, timestamp); } else { // use SSO serviceBundle = Authentication; endpoint = "login"; json.AddField("username", username); json.AddField("email", username); json.AddField("password", password); } body = json.Print (); KnetikRequest req = CreateRequest(endpoint, body, "post", timestamp, serviceBundle); KnetikApiResponse res = new KnetikLoginResponse(this, req, cb); return res; }
public KnetikApiResponse GuestLogin( Action<KnetikApiResponse> cb = null ) { Username = ""; Password = ""; Session = ""; JSONObject json = new JSONObject (JSONObject.Type.OBJECT); json.AddField ("serial", KnetikApiUtil.getDeviceSerial()); json.AddField ("mac_address", KnetikApiUtil.getMacAddress ()); // Device Type is currently limited to 3 characters in the DB json.AddField ("device_type", KnetikApiUtil.getDeviceType()); json.AddField ("signature", KnetikApiUtil.getDeviceSignature()); String body = json.Print(); KnetikRequest req = CreateRequest(SessionEndpoint, body); KnetikApiResponse res = new KnetikLoginResponse(this, req, cb); return res; }
public KnetikApiResponse UpgradeFromRegisteredGuest( string username, string password, string email, string fullname, Action<KnetikApiResponse> cb = null ) { JSONObject j = new JSONObject (JSONObject.Type.OBJECT); j.AddField ("username", username); j.AddField ("password", password); j.AddField ("email", email); j.AddField ("fullname", fullname); String body = j.Print (); KnetikRequest req = CreateRequest(UpgradeFromRegisteredGuestEndpoint, body); KnetikApiResponse registerResponse = new KnetikApiResponse(this, req, cb); return registerResponse; }