Exemplo n.º 1
0
    private void GetFriendsCallback(IResult result)
    {
        if (debugInfo)
        {
            FacebookHelperDebug("GetFriendsCallback");
        }
        if (result == null)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Null Response\n");
            }
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Error Response:\n" + result.Error);
            }
        }
        else if (result.Cancelled)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Cancelled Response:\n" + result.RawResult);
            }
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Success Response:\n" + result.RawResult);
            }
            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;
                //UserModel user = GameManager.Instance.User;
                //for(int i = 0; i < friends.Count; i++)
                //{
                //    MTJSONObject friendJson = friends[i];
                //    FriendModel friendModel = user.GetFriendModel(friendJson.GetString("id", ""), true);
                //    friendModel.Name = friendJson.GetString("name", "");

                //    AddDownloadPictureId(friendModel.Id);
                //}
                //Tracker.Instance.FacebookGameFriendsCount(_currFacebookId, friends.Count);
            }
        }
        else
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Empty Response\n");
            }
        }
    }
Exemplo n.º 2
0
    private void GetInviteFriendsCallback(IResult result)
    {
        if (debugInfo)
        {
            FacebookHelperDebug("GetInviteFriendsCallback");
        }
        if (result == null)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Null Response\n");
            }
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Error Response:\n" + result.Error);
            }
        }
        else if (result.Cancelled)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Cancelled Response:\n" + result.RawResult);
            }
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Success Response:\n" + result.RawResult);
            }
            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;
                _inviteFriends.Clear();
                for (int i = 0; i < friends.Count; i++)
                {
                    string id = friends[i].GetString("id", "");
                    if (id.Length > 0)
                    {
                        _inviteFriends.Add(id);
                    }
                }
            }
        }
        else
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Empty Response\n");
            }
        }
    }
Exemplo n.º 3
0
    private void GetFriendsCallback(IResult result)
    {
        FacebookHelperDebug("GetFriendsCallback");
        if (result == null)
        {
            FacebookHelperDebug("GetFriendsCallback Null Response\n");
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            FacebookHelperDebug("GetFriendsCallback Error Response:\n" + result.Error);
        }
        else if (result.Cancelled)
        {
            FacebookHelperDebug("GetFriendsCallback Cancelled Response:\n" + result.RawResult);
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            ShowInvite();
            FacebookHelperDebug("GetFriendsCallback Success Response:\n" + result.RawResult);

            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;

                for (int i = 0; i < friends.Count; i++)
                {
                    MTJSONObject friendJson  = friends[i];
                    FriendModel  friendModel = _user.GetFriendModel(friendJson.GetString("id", ""), true);
                    friendModel.Name = friendJson.GetString("name", "");
                    FacebookInviteMgr.current.AddIcon(friendModel);

                    AddDownloadPictureId(friendModel.Id);
                }
                // Tracker.Instance.FacebookGameFriendsCount(_currFacebookId, friends.Count);
            }
        }
        else
        {
            FacebookHelperDebug("GetFriendsCallback Empty Response\n");
        }
    }
Exemplo n.º 4
0
    public void DeserializeFromJson(MTJSONObject curJson, bool sync)
    {
        Id       = curJson.GetString("id", Id);
        Name     = curJson.GetString("name", Name);
        MaxLevel = curJson.GetInt("maxLevel", MaxLevel);

        //  levels
        MTJSONObject levelsJson = curJson.Get("levels");

        if (levelsJson != null)
        {
            if (!sync)
            {
                _levels.Clear();
            }

            if (levelsJson.count > 0)
            {
                var itemEnum = levelsJson.dict.GetEnumerator();
                while (itemEnum.MoveNext())
                {
                    string curKey    = itemEnum.Current.Key;
                    int    curValue  = itemEnum.Current.Value.i;
                    int    curKeyInt = Convert.ToInt32(curKey);

                    if (!_levels.ContainsKey(curKeyInt))
                    {
                        _levels.Add(curKeyInt, curValue);
                    }
                    else
                    {
                        _levels[curKeyInt] = curValue;
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
        IEnumerator sendLoop()
        {
            while (true)
            {
                yield return(new WaitForSeconds(_lastSucc ? sendInterval : retryDelay));

                if (_queue == null)
                {
                    LoadQueue();
                }

                if (_queue == null || _queue.Count == 0)
                {
                    continue;
                }

                PurchaseBillingItem item = _queue [0];

                // sign
                string sign = MTSecurity.Md5Sum(item.message + signKey);
                Debug.Log("[MTPBHelper] Sending check: " + item.message + "," + item.iapKey);
                Dictionary <string, string> headers = new Dictionary <string, string> ();
                headers ["sign"]         = sign;
                headers ["Content-Type"] = "application/json";
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes(item.message);
#pragma warning disable CS0618 // 类型或成员已过时
                WWW www = new WWW(baseUrl, bytes, headers);
                yield return(www);

                if (www.error != null)
                {
                    Debug.Log("[MTPBHelper] send Error: " + www.error);
                    _lastSucc = false;
                }
                else                     // success, remove from queue
                {
                    _queue.RemoveAt(0);
                    _queueDirty = true;
                    _lastSucc   = true;

                    int code = 1;
                    if (www.text == null)
                    {
                        Debug.LogError("[MTPBHelper] www.text = null");
                    }
                    else
                    {
                        MTJSONObject jObject = MTJSON.Deserialize(www.text);
                        if (jObject == null)
                        {
                            Debug.LogError("[MTPBHelper] JSON Object (www.text) = null");
                            code = 2;
                            AddKey(new PurchaseResult(item.iapKey, code));
                        }
                        else
                        {
                            jObject = jObject.Get("ret_status");
                            if (jObject == null)
                            {
                                Debug.LogError("[MTPBHelper] ret_status = null, www.text = " + www.text);
                                code = 3;
                                AddKey(new PurchaseResult(item.iapKey, code));
                            }
                            else
                            {
                                Debug.Log("[MTPBHelper] send Succ  code = " + code);
                                code = jObject.i;
                                AddKey(new PurchaseResult(item.iapKey, code));
                            }
                        }
                    }
                    OnCheckFinished(code, item.iapKey);
                }
            }
        }
Exemplo n.º 6
0
 public void ClearRequests()
 {
     if (IsLoggedIn)
     {
         FB.API("me/apprequests", HttpMethod.GET, delegate(IGraphResult result)
         {
             if (debugInfo)
             {
                 FacebookHelperDebug("ClearRequests");
             }
             if (result == null)
             {
                 if (debugInfo)
                 {
                     FacebookHelperDebug("ClearRequests Null Response\n");
                 }
             }
             else
             {
                 if (!string.IsNullOrEmpty(result.Error))
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Error Response:\n" + result.Error);
                     }
                 }
                 else if (result.Cancelled)
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Cancelled Response:\n" + result.RawResult);
                     }
                 }
                 else if (!string.IsNullOrEmpty(result.RawResult))
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Success Response:\n" + result.RawResult);
                     }
                     MTJSONObject mtJson         = MTJSON.Deserialize(result.RawResult);
                     List <MTJSONObject> friends = mtJson.Get("data").list;
                     for (int i = 0; i < friends.Count; i++)
                     {
                         string id = friends[i].GetString("id", "");
                         if (id.Length > 0)
                         {
                             FB.API(id, HttpMethod.DELETE, delegate(IGraphResult deleteResult)
                             {
                                 if (debugInfo)
                                 {
                                     FacebookHelperDebug("DeleteRequests" + id);
                                 }
                                 if (deleteResult == null)
                                 {
                                     if (debugInfo)
                                     {
                                         FacebookHelperDebug("DeleteRequests Null Response\n" + id);
                                     }
                                 }
                                 else
                                 {
                                     if (!string.IsNullOrEmpty(deleteResult.Error))
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Error Response:\n" + deleteResult.Error + ", id = " + id);
                                         }
                                     }
                                     else if (deleteResult.Cancelled)
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Cancelled Response:\n" + deleteResult.RawResult + ", id = " + id);
                                         }
                                     }
                                     else if (!string.IsNullOrEmpty(deleteResult.RawResult))
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Success Response:\n" + deleteResult.RawResult + ", id = " + id);
                                         }
                                     }
                                     else
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Empty Response\n" + id);
                                         }
                                     }
                                 }
                             });
                         }
                     }
                 }
                 else
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Empty Response\n");
                     }
                 }
             }
         });
     }
 }
Exemplo n.º 7
0
    private void GetInviteFriendsCallback(IResult result)
    {
        if (debugInfo)
        {
            FacebookHelperDebug("GetInviteFriendsCallback");
        }
        if (result == null)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Null Response\n");
            }
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Error Response:\n" + result.Error);
            }
        }
        else if (result.Cancelled)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Cancelled Response:\n" + result.RawResult);
            }
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Success Response:\n" + result.RawResult);
            }
            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;
                _inviteFriends.Clear();
                for (int i = 0; i < friends.Count; i++)
                {
                    MTJSONObject friendJson  = friends[i];
                    FriendModel  friendModel = _user.GetFriendModel(friendJson.GetString("id", ""), true);
                    friendModel.Name = friendJson.GetString("name", "");
                    FacebookInviteMgr.current.AddIcon(friendModel);

                    AddDownloadPictureId(friendModel.Id);

                    //string id = friends[i].GetString("id", "");
                    //if (id.Length > 0)
                    //{
                    //    _inviteFriends.Add(id);
                    //}
                }
            }
        }
        else
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Empty Response\n");
            }
        }
    }