Print() 공개 메소드

public Print ( bool pretty = false ) : string
pretty bool
리턴 string
예제 #1
0
    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);
    }
예제 #2
0
    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());
    }
예제 #3
0
        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);
        }
예제 #4
0
    //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());
    }
예제 #5
0
        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;
        }
예제 #6
0
 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());
            }
        }
    }
예제 #8
0
        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());
        }
예제 #9
0
        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
        }
예제 #10
0
        /// <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));
        }
예제 #11
0
    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");
        }
    }
예제 #12
0
    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());
        }
예제 #14
0
        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;
        }
예제 #15
0
    /*
     * 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);
        }
    }
예제 #16
0
    /*
     * 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();
        }
    }
예제 #17
0
        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());
        }
예제 #18
0
    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);
    }
예제 #19
0
        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
        }
예제 #20
0
    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();
        }
    }
예제 #21
0
    private void OnReceiveMessage(SocketIOEvent evt)
    {
        JSONObject obj = evt.data.list[0];
        string     msg = obj.Print().Replace("\"", "");

        chatManager.ReceiveMessage(msg);
    }
예제 #22
0
    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)));
            }
        }
    }
예제 #23
0
    //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;
        }
    }
예제 #24
0
    internal void SendMessage(string en)
    {
        JSONObject data = new JSONObject();

        data.AddField("type", en);
        w.Send(data.Print());
    }
예제 #25
0
    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);
    }
예제 #26
0
    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();
    }
예제 #27
0
        public static string encodeBoardState(string boardState)
        {
            JSONObject jObj = new JSONObject();

            jObj.AddField(Constants.Fields.boardState, boardState);
            return(jObj.Print());
        }
예제 #28
0
    /// <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());
        }
    }
예제 #29
0
        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());
    }
예제 #31
0
    // 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();
    }
예제 #32
0
 /// <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 플래그 내리기
     }
 }
예제 #33
0
    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();
    }
예제 #34
0
    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);
    }
예제 #35
0
        private string GetPongMessage()
        {
            JSONObject message = new JSONObject(JSONObject.Type.OBJECT);

            message.AddField(Field.MSG, MessageType.PONG);

            return(message.Print());
        }
예제 #36
0
파일: LevelSaver.cs 프로젝트: mahnovsky/PT
	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)));
	}
예제 #37
0
        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;
        }
예제 #38
0
		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;
		}
예제 #39
0
        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";
        }
예제 #41
0
        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;
        }
예제 #42
0
 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;
 }
예제 #43
0
        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;
        }
예제 #44
0
        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;
        }
예제 #45
0
        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;
        }
예제 #46
0
        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;
        }
예제 #47
0
        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);
        }
예제 #48
0
        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;
        }
예제 #49
0
        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;
        }
예제 #50
0
 //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 ();
 }
예제 #51
0
 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;
 }
예제 #52
0
 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;
 }
예제 #53
0
	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 ();
	}
예제 #54
0
        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;
        }
예제 #55
0
        /*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;
        }
예제 #56
0
        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;
        }
예제 #57
0
    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 ("******");

        }
    }
예제 #58
0
        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;
        }
예제 #59
0
        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;
        }
예제 #60
0
        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;
        }