コード例 #1
0
    public IEnumerator callContract(ContractName contractName, object arg0, object arg1)
    {
        var address = ConvertHexStringToByteArray("cf2cc8dcffc74cfe0a079fdbb16c0d6f78290527bfbcef935553d50746ecc00f");

        switch (contractName)
        {
        case ContractName.Win:
            var winReq = new WinRequest(address);
            yield return(winReq.Win((byte[])arg0, (string)arg1));

            printProcessResult(winReq);     //log
            break;

        case ContractName.Rent:
            var rentReq = new RentRequest(address);
            yield return(rentReq.Rent((string)arg0, (int)arg1));

            printProcessResult(rentReq);
            break;

        case ContractName.CreatePatent:
            var patentReq = new NewVirusRequest(address);
            yield return(patentReq.NewVirus((string)arg0, (int)arg1));

            printProcessResult(patentReq);

            break;
        }
    }
コード例 #2
0
    private IEnumerator createNewVirusAsync()
    {
        //Proyecto26.RestClient.Get("http://ya.ru").Then(response => {
        //    UnityEditor.EditorUtility.DisplayDialog("Response", response.Text, "Ok");
        //});

        float[] coords = new float[12] {
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
        };
        int my_count = 0;

        foreach (Transform cur_dna_node in this.dnaNodeList)
        {
            coords[my_count] = cur_dna_node.position.x;
            my_count++;
        }

        var usersRoute = "http://localhost:8080/";
        var testRoute  = "https://jsonplaceholder.typicode.com/posts";
        var newUser    = 1;

        //Proyecto26.RestClient.Post<CustomResponse>(usersRoute, newUser).Then(customResponse => {
        //    UnityEditor.EditorUtility.DisplayDialog("JSON", JsonUtility.ToJson(customResponse, true), "Ok");
        //});
        Debug.Log(Proyecto26.RestClient.Post <CustomResponse>(usersRoute, this.dnaNodeList.Count).Then(customResponse => {
            UnityEditor.EditorUtility.DisplayDialog("JSON", JsonUtility.ToJson(customResponse, true), "Ok");
        }));
        Debug.Log(Proyecto26.RestClient.Post <CustomResponse2>(usersRoute, coords).Then(customResponse => {
            UnityEditor.EditorUtility.DisplayDialog("JSON", JsonUtility.ToJson(customResponse, true), "Ok");
        }));
        //Debug.Log(Proyecto26.RestClient.Post<CustomResponse>(testRoute, newUser).Then(customResponse => {
        //    UnityEditor.EditorUtility.DisplayDialog("JSON", JsonUtility.ToJson(customResponse, true), "Ok");
        //}));
        //Debug.Log(Proyecto26.RestClient.Get("http://ya.ru"));


        //Proyecto26.RestClient.Post("https://jsonplaceholder.typicode.com/posts", newPost).Then(response => {
        //    UnityEditor.EditorUtility.DisplayDialog("Status", response.StatusCode.ToString(), "Ok");
        //});

        var address = ConvertHexStringToByteArray("cf2cc8dcffc74cfe0a079fdbb16c0d6f78290527bfbcef935553d50746ecc00f");

        var newVirusContract = new NewVirusRequest(address);

        string hash = CulcVirusHash();

        float rentCost = 10;

        if (rentCost >= 0)
        {
            print("start add patent");
            yield return(newVirusContract.NewVirus(hash, Mathf.RoundToInt(rentCost)));

            printProcessResult(newVirusContract);
            print(rentCost);
        }
    }