void OnGet5FriendsCompleted(VkResponseRaw arg1, object[] arg2)
    {
        //проверяем на ошибки
        if (arg1.ei != null) {
            //если ошибка, помним что мы передали номер запроса, можно повторить запрос некоторое количество раз
            var attempt=(int)arg2[0];
            if(attempt<5)
            {
                Get3FriendsDataFromVk(attempt+1);
            }
            return;
        }

        var dict=Json.Deserialize(arg1.text) as Dictionary<string,object>;
        var resp= (Dictionary<string,object>)dict["response"];
        var items=(List<object>)resp["items"];

        foreach(var item in items)
        {
            friends.Add(VKUser.Deserialize(item));
        }
        for(var i=0;i<3;i++)
        {
            var friendsOnScene=GameObject.FindObjectsOfType<FriendManager>();

            Action<WWW, object[]> doOnFinish =(www,objarray)=>
            {
                var friendCard=(FriendManager)objarray[0];
                friendCard.setUpImage(www.bytes);
            };
            friendsOnScene[i].t.text=friends[i].first_name;
            d.download(friends[i].photo_200,doOnFinish,new object[]{friendsOnScene[i]});
        }
    }
Exemple #2
0
        private void HandleNoError(WWW www, string requestString, Action <VkResponseRaw, object[]> CallbackFunction, object[] data = null)
        {
            VkResponseRaw vkargs = new VkResponseRaw();

            vkargs.request = requestString;
            vkargs.text    = www.text;
            if (CallbackFunction != null)
            {
                CallbackFunction(vkargs, data);
            }
        }
Exemple #3
0
        private void HandleVKError(WWW www, string requestString, Action <VkResponseRaw, object[]> CallbackFunction, object[] data = null)
        {
            var           vkerror = ParseVkError(www.text);
            VkResponseRaw vkargs  = new VkResponseRaw()
            {
                request = requestString,
                text    = www.text
            };

            vkargs.ei = vkerror;

            if (CallbackFunction != null)
            {
                CallbackFunction(vkargs, data);
            }
        }
Exemple #4
0
        private void HandleTokenExpired(string fullHttpRequestString, Action <VkResponseRaw, object[]> CallbackFunction, object[] data = null)
        {
            Debug.Log("Invalid token. Are you logged in?");
            VkResponseRaw vkargs = new VkResponseRaw();

            vkargs.request = fullHttpRequestString;
            vkargs.text    = "";

            vkargs.ei = new Error {
                error_code = "401", error_msg = "invalid token"
            };
            if (CallbackFunction != null)
            {
                CallbackFunction(vkargs, data);
            }
        }
Exemple #5
0
        private void HandleWWWError(WWW www, string requestString, Action <VkResponseRaw, object[]> CallbackFunction, object[] data = null)
        {
            var vkerror = new Error()
            {
                error_code = "404",
                error_msg  = www.error
            };

            VkResponseRaw vkargs = new VkResponseRaw()
            {
                request = requestString,
                text    = www.text
            };

            vkargs.ei = vkerror;

            if (CallbackFunction != null)
            {
                CallbackFunction(vkargs, data);
            }
        }
Exemple #6
0
    public void JoinGroupHandler(VkResponseRaw _raw, object[] _arguments)
    {
        if (_raw.ei != null && _raw.ei.error_code.Equals("17"))
        {
            libraryMenu.windowWarning.Show("ВКонтакте требует прохождения процедуры валидации пользователя.");
            return;
        }

        var dict = Json.Deserialize(_raw.text) as Dictionary<string, object>;
        long resp = (long) dict["response"];

        if (resp == 1)
        {
            PreferencesSaver.UserJoinInGroupVK();
            PreferencesSaver.OpenCar(numBonusCar);
            libraryMenu.carChanger.ShowCar();
        }
        else
        {
            libraryMenu.windowWarning.Show("Превышено ограничение на количество вступлений.");
        }
    }
Exemple #7
0
        private void HandleWWWError( WWW www,string requestString,Action<VkResponseRaw,object[]> CallbackFunction,object[]data=null)
        {
            var vkerror=new Error()
            {
                error_code="404",
                error_msg=www.error
            };

            VkResponseRaw vkargs = new VkResponseRaw ()
            {request = requestString,
                text = www.text};

            vkargs.ei=vkerror;

            if(CallbackFunction!=null)
                CallbackFunction (vkargs,data);
        }
Exemple #8
0
        private void HandleVKError( WWW www,string requestString,Action<VkResponseRaw,object[]> CallbackFunction,object[]data=null)
        {
            var vkerror=ParseVkError(www.text);
            VkResponseRaw vkargs = new VkResponseRaw ()
            {request = requestString,
                text = www.text};

            vkargs.ei=vkerror;

            if(CallbackFunction!=null)
                CallbackFunction (vkargs,data);
        }
Exemple #9
0
        private void HandleTokenExpired(string fullHttpRequestString, Action<VkResponseRaw,object[]> CallbackFunction,object[]data=null)
        {
            Debug.Log("Invalid token. Are you logged in?");
                VkResponseRaw vkargs = new VkResponseRaw ();
                vkargs.request = fullHttpRequestString;
                vkargs.text = "";

                vkargs.ei=new Error{error_code="401",error_msg="invalid token" };
                if(CallbackFunction!=null)
                    CallbackFunction (vkargs,data);
        }
Exemple #10
0
 private void HandleNoError( WWW www,string requestString,Action<VkResponseRaw,object[]> CallbackFunction,object[]data=null)
 {
     VkResponseRaw vkargs = new VkResponseRaw ();
     vkargs.request = requestString;
     vkargs.text = www.text;
     if(CallbackFunction!=null)
         CallbackFunction (vkargs,data);
 }