示例#1
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 public virtual void VerifyHsTaskAttempt(JSONObject info, TaskAttempt att, TaskType
                                         ttype)
 {
     if (ttype == TaskType.Reduce)
     {
         NUnit.Framework.Assert.AreEqual("incorrect number of elements", 17, info.Length()
                                         );
     }
     else
     {
         NUnit.Framework.Assert.AreEqual("incorrect number of elements", 12, info.Length()
                                         );
     }
     VerifyTaskAttemptGeneric(att, ttype, info.GetString("id"), info.GetString("state"
                                                                               ), info.GetString("type"), info.GetString("rack"), info.GetString("nodeHttpAddress"
                                                                                                                                                 ), info.GetString("diagnostics"), info.GetString("assignedContainerId"), info.GetLong
                                  ("startTime"), info.GetLong("finishTime"), info.GetLong("elapsedTime"), (float)info
                              .GetDouble("progress"));
     if (ttype == TaskType.Reduce)
     {
         VerifyReduceTaskAttemptGeneric(att, info.GetLong("shuffleFinishTime"), info.GetLong
                                            ("mergeFinishTime"), info.GetLong("elapsedShuffleTime"), info.GetLong("elapsedMergeTime"
                                                                                                                  ), info.GetLong("elapsedReduceTime"));
     }
 }
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 public virtual void VerifyAMSingleTask(JSONObject info, Task task)
 {
     NUnit.Framework.Assert.AreEqual("incorrect number of elements", 9, info.Length());
     VerifyTaskGeneric(task, info.GetString("id"), info.GetString("state"), info.GetString
                           ("type"), info.GetString("successfulAttempt"), info.GetLong("startTime"), info.GetLong
                           ("finishTime"), info.GetLong("elapsedTime"), (float)info.GetDouble("progress"),
                       info.GetString("status"));
 }
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 /// <exception cref="System.Exception"/>
 public virtual void VerifyNodeInfo(JSONObject nodeInfo, MockNM nm)
 {
     NUnit.Framework.Assert.AreEqual("incorrect number of elements", 13, nodeInfo.Length
                                         ());
     VerifyNodeInfoGeneric(nm, nodeInfo.GetString("state"), nodeInfo.GetString("rack")
                           , nodeInfo.GetString("id"), nodeInfo.GetString("nodeHostName"), nodeInfo.GetString
                               ("nodeHTTPAddress"), nodeInfo.GetLong("lastHealthUpdate"), nodeInfo.GetString("healthReport"
                                                                                                             ), nodeInfo.GetInt("numContainers"), nodeInfo.GetLong("usedMemoryMB"), nodeInfo.
                           GetLong("availMemoryMB"), nodeInfo.GetLong("usedVirtualCores"), nodeInfo.GetLong
                               ("availableVirtualCores"), nodeInfo.GetString("version"));
 }
示例#4
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyClusterInfo(JSONObject json)
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject info = json.GetJSONObject("clusterInfo");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 12, info.Length()
                                            );
            VerifyClusterGeneric(info.GetLong("id"), info.GetLong("startedOn"), info.GetString
                                     ("state"), info.GetString("haState"), info.GetString("haZooKeeperConnectionState"
                                                                                          ), info.GetString("hadoopVersionBuiltOn"), info.GetString("hadoopBuildVersion"),
                                 info.GetString("hadoopVersion"), info.GetString("resourceManagerVersionBuiltOn")
                                 , info.GetString("resourceManagerBuildVersion"), info.GetString("resourceManagerVersion"
                                                                                                 ));
        }
示例#5
0
	public void SetUser(JSONObject user) {
	  username = user.GetString("username");
		password = user.GetString("password");
		displayName = user.GetString("displayName");
		cash = user.GetLong("cash");
		gem = user.GetInt("gem");
		bossKilled = user.GetInt("bossKill");
		lastClaimedDaily = user.GetLong("lastDaily");
		fbId = user.GetString("facebookId");
		avatarLink = user.GetString("avatar");
		lastReadInboxTime = user.GetLong("lastReadInboxTime");
		lastInboxTime = user.GetLong("lastInboxTime");
		Debug.Log("SetUser " + user.ToString());
		// friends = user.GetArray("friends");
	}
示例#6
0
  public void UpdateRowData(JSONObject data) {
    rowData = data;
		titleLabel.text = rowData.GetString("title");
		messageTimeSeconds = (int)((Utils.UTCNowMiliseconds() - data.GetLong("createdAt")) / 1000);
		timeLabel.text = Utils.GetTimePassed(messageTimeSeconds);
    EventDelegate.Set(eventTrigger.onClick, EventViewMessage);
  }
示例#7
0
 public void SetUser(JSONObject user)
 {
     username          = user.GetString("username");
     password          = user.GetString("password");
     displayName       = user.GetString("displayName");
     cash              = user.GetLong("cash");
     gem               = user.GetInt("gem");
     bossKilled        = user.GetInt("bossKill");
     lastClaimedDaily  = user.GetLong("lastDaily");
     fbId              = user.GetString("facebookId");
     avatarLink        = user.GetString("avatar");
     lastReadInboxTime = user.GetLong("lastReadInboxTime");
     lastInboxTime     = user.GetLong("lastInboxTime");
     Debug.Log("SetUser " + user.ToString());
     // friends = user.GetArray("friends");
 }
示例#8
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        public virtual void VerifyHsJobTaskAttemptCounters(JSONObject info, TaskAttempt att
                                                           )
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 2, info.Length());
            WebServicesTestUtils.CheckStringMatch("id", MRApps.ToString(att.GetID()), info.GetString
                                                      ("id"));
            // just do simple verification of fields - not data is correct
            // in the fields
            JSONArray counterGroups = info.GetJSONArray("taskAttemptCounterGroup");

            for (int i = 0; i < counterGroups.Length(); i++)
            {
                JSONObject counterGroup = counterGroups.GetJSONObject(i);
                string     name         = counterGroup.GetString("counterGroupName");
                NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
                JSONArray counters = counterGroup.GetJSONArray("counter");
                for (int j = 0; j < counters.Length(); j++)
                {
                    JSONObject counter     = counters.GetJSONObject(j);
                    string     counterName = counter.GetString("name");
                    NUnit.Framework.Assert.IsTrue("name not set", (counterName != null && !counterName
                                                                   .IsEmpty()));
                    long value = counter.GetLong("value");
                    NUnit.Framework.Assert.IsTrue("value  >= 0", value >= 0);
                }
            }
        }
  public void UpdateRowData(JSONObject data, LeaderboardScreen.Tab selectedTab) {
    rowData = data;
    
    if (AccountManager.Instance.IsYou(rowData.GetString("username"))) {
      background.spriteName = "PopupBackground";
    } else {
      background.spriteName = "Global_Window_Paper";
    }
    
    playerNameLabel.text = rowData.GetString("displayName");
    if (selectedTab == LeaderboardScreen.Tab.TOP_RICHER) {
      cashLabel.text = rowData.GetLong("cash").ToString("N0") + "$";
    } else {
      // cashLabel.text = Utils.Localize("Top_Winner_Match_Text", new string[1] {rowData.GetInt("winMatchNumb").ToString("N0")});
      cashLabel.text = Localization.Format("Top_Winner_Match_Text", rowData.GetInt("bossKill").ToString("N0"));
    }
    rank = rowData.GetInt("rank");
    if (rank <= 3) {
			Utils.SetActive(rankBackground, false);
			Utils.SetActive(rankIcon.gameObject, true);
      rankIcon.spriteName = "Chat_RankIcon0" + rank;
    } else {
			Utils.SetActive(rankBackground, true);
			Utils.SetActive(rankIcon.gameObject, false);
      rankLabel.text = rank.ToString();
    }
    eventTrigger.inputParams = new object[] {rowData.GetString("username")};
    EventDelegate.Set(eventTrigger.onClick, delegate() { EventShowUserInfo((string)eventTrigger.inputParams[0]); });
  }
示例#10
0
 public void UpdateRowData(JSONObject data)
 {
     rowData            = data;
     titleLabel.text    = rowData.GetString("title");
     messageTimeSeconds = (int)((Utils.UTCNowMiliseconds() - data.GetLong("createdAt")) / 1000);
     timeLabel.text     = Utils.GetTimePassed(messageTimeSeconds);
     EventDelegate.Set(eventTrigger.onClick, EventViewMessage);
 }
示例#11
0
 void ClaimDailyRewardSuccess(JSONObject data)
 {
     ErrorCode.USER errorCode = (ErrorCode.USER)data.GetInt("errorCode");
     if (errorCode == ErrorCode.USER.NULL)
     {
         Debug.Log("ClaimDailyRewardSuccess-- " + data.ToString());
         AccountManager.Instance.lastClaimedDaily = data.GetLong("lastDaily");
         AccountManager.Instance.UpdateUserCash(data.GetLong("cash"));
         if (ScreenManager.Instance.SelectGameScreen != null)
         {
             ScreenManager.Instance.SelectGameScreen.ClaimedDailyRewardCallback();
         }
     }
     else
     {
         Debug.Log("ClaimDailyRewardFail-- " + data.ToString());
         HUDManager.Instance.AddFlyText(errorCode.ToString(), Vector3.zero, 40, Color.red);
     }
 }
示例#12
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        public static void VerifyHsJob(JSONObject info, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                                       job)
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 25, info.Length()
                                            );
            // everyone access fields
            VerifyHsJobGeneric(job, info.GetString("id"), info.GetString("user"), info.GetString
                                   ("name"), info.GetString("state"), info.GetString("queue"), info.GetLong("startTime"
                                                                                                            ), info.GetLong("finishTime"), info.GetInt("mapsTotal"), info.GetInt("mapsCompleted"
                                                                                                                                                                                 ), info.GetInt("reducesTotal"), info.GetInt("reducesCompleted"));
            string diagnostics = string.Empty;

            if (info.Has("diagnostics"))
            {
                diagnostics = info.GetString("diagnostics");
            }
            // restricted access fields - if security and acls set
            VerifyHsJobGenericSecure(job, info.GetBoolean("uberized"), diagnostics, info.GetLong
                                         ("avgMapTime"), info.GetLong("avgReduceTime"), info.GetLong("avgShuffleTime"), info
                                     .GetLong("avgMergeTime"), info.GetInt("failedReduceAttempts"), info.GetInt("killedReduceAttempts"
                                                                                                                ), info.GetInt("successfulReduceAttempts"), info.GetInt("failedMapAttempts"), info
                                     .GetInt("killedMapAttempts"), info.GetInt("successfulMapAttempts"));
        }
示例#13
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyNodeInfo(JSONObject json)
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject info = json.GetJSONObject("nodeInfo");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 16, info.Length()
                                            );
            VerifyNodeInfoGeneric(info.GetString("id"), info.GetString("healthReport"), info.
                                  GetLong("totalVmemAllocatedContainersMB"), info.GetLong("totalPmemAllocatedContainersMB"
                                                                                          ), info.GetLong("totalVCoresAllocatedContainers"), info.GetBoolean("vmemCheckEnabled"
                                                                                                                                                             ), info.GetBoolean("pmemCheckEnabled"), info.GetLong("lastNodeUpdateTime"), info
                                  .GetBoolean("nodeHealthy"), info.GetString("nodeHostName"), info.GetString("hadoopVersionBuiltOn"
                                                                                                             ), info.GetString("hadoopBuildVersion"), info.GetString("hadoopVersion"), info.GetString
                                      ("nodeManagerVersionBuiltOn"), info.GetString("nodeManagerBuildVersion"), info.GetString
                                      ("nodeManagerVersion"));
        }
示例#14
0
  public void UpdateRowData(JSONObject data) {
		if (rowData != null && data.GetString("username") == rowData.GetString("username")) {
			return;
		}
    rowData = data;
		facebookID = rowData.GetString("facebookId");
    usernameLabel.text = data.GetString("displayName");
    cashLabel.text = data.GetLong("cash").ToString("N0");
		if (facebookID != null && facebookID != string.Empty) {
			NGUITools.SetActive(avatarTexture.gameObject, true);
			StartCoroutine(DisplayAvatar(facebookID));
		} else {
			NGUITools.SetActive(defaultAvatar, true);
			NGUITools.SetActive(avatarTexture.gameObject, false);
		}
  }
示例#15
0
  public void DisplayUserInfo(JSONObject mUser) {
		Debug.Log("mUser " + mUser.ToString());
		Utils.SetActive(userInfoPanel, true);
    user = mUser;
    displayNameLabel.text = user.GetString("displayName");
    cashLabel.text = user.GetLong("cash").ToString("N0");
    killLabel.text = user.GetInt("bossKill").ToString("N0");
		avatarLink = user.GetString("avatar");
		if (avatarLink != string.Empty) {
			NGUITools.SetActive(avatarSprite.gameObject, true);
			NGUITools.SetActive(defaultAvatar, false);
			StartCoroutine(DisplayAvatar());
		} else {
			NGUITools.SetActive(avatarSprite.gameObject, false);
			NGUITools.SetActive(defaultAvatar, true);
		}
		Utils.SetActive(btnAddFriend.gameObject, !AccountManager.Instance.IsFriend(user.GetString("username")));
  }
示例#16
0
    // TO DO: update gem val
    public void ClaimRewardSuccess(JSONObject jsonData)
    {
        Debug.Log("ClaimRewardSuccess " + jsonData.ToString());
        AccountManager.Instance.UpdateUserCash(jsonData.GetInt("goldVal"));
        AccountManager.Instance.UpdateUserGem(jsonData.GetInt("gemVal"));
        JSONObject message;

        for (int i = 0; i < messageList.Length; i++)
        {
            message = messageList[i].Obj;
            if (message.GetLong("createdAt") == selectMessage.GetLong("createdAt") && message.GetInt("type") == selectMessage.GetInt("type") && (string.IsNullOrEmpty(selectMessage.GetString("fromUsername")) || message.GetString("fromUsername") == selectMessage.GetString("fromUsername")))
            {
                messageList.Remove(i);
                break;
            }
        }
        EventBackToListMessages();
        InitScrollViewData();
        HUDManager.Instance.AddFlyText(Localization.Get("PopupInbox_ClaimSuccess"), Vector3.zero, 40, Color.green);
    }
示例#17
0
 public void UpdateRowData(JSONObject data)
 {
     if (rowData != null && data.GetString("username") == rowData.GetString("username"))
     {
         return;
     }
     rowData            = data;
     facebookID         = rowData.GetString("facebookId");
     usernameLabel.text = data.GetString("displayName");
     cashLabel.text     = data.GetLong("cash").ToString("N0");
     if (facebookID != null && facebookID != string.Empty)
     {
         NGUITools.SetActive(avatarTexture.gameObject, true);
         StartCoroutine(DisplayAvatar(facebookID));
     }
     else
     {
         NGUITools.SetActive(defaultAvatar, true);
         NGUITools.SetActive(avatarTexture.gameObject, false);
     }
 }
示例#18
0
 public void DisplayUserInfo(JSONObject mUser)
 {
     Debug.Log("mUser " + mUser.ToString());
     Utils.SetActive(userInfoPanel, true);
     user = mUser;
     displayNameLabel.text = user.GetString("displayName");
     cashLabel.text        = user.GetLong("cash").ToString("N0");
     killLabel.text        = user.GetInt("bossKill").ToString("N0");
     avatarLink            = user.GetString("avatar");
     if (avatarLink != string.Empty)
     {
         NGUITools.SetActive(avatarSprite.gameObject, true);
         NGUITools.SetActive(defaultAvatar, false);
         StartCoroutine(DisplayAvatar());
     }
     else
     {
         NGUITools.SetActive(avatarSprite.gameObject, false);
         NGUITools.SetActive(defaultAvatar, true);
     }
     Utils.SetActive(btnAddFriend.gameObject, !AccountManager.Instance.IsFriend(user.GetString("username")));
 }
    public void UpdateRowData(JSONObject data, LeaderboardScreen.Tab selectedTab)
    {
        rowData = data;

        if (AccountManager.Instance.IsYou(rowData.GetString("username")))
        {
            background.spriteName = "PopupBackground";
        }
        else
        {
            background.spriteName = "Global_Window_Paper";
        }

        playerNameLabel.text = rowData.GetString("displayName");
        if (selectedTab == LeaderboardScreen.Tab.TOP_RICHER)
        {
            cashLabel.text = rowData.GetLong("cash").ToString("N0") + "$";
        }
        else
        {
            // cashLabel.text = Utils.Localize("Top_Winner_Match_Text", new string[1] {rowData.GetInt("winMatchNumb").ToString("N0")});
            cashLabel.text = Localization.Format("Top_Winner_Match_Text", rowData.GetInt("bossKill").ToString("N0"));
        }
        rank = rowData.GetInt("rank");
        if (rank <= 3)
        {
            Utils.SetActive(rankBackground, false);
            Utils.SetActive(rankIcon.gameObject, true);
            rankIcon.spriteName = "Chat_RankIcon0" + rank;
        }
        else
        {
            Utils.SetActive(rankBackground, true);
            Utils.SetActive(rankIcon.gameObject, false);
            rankLabel.text = rank.ToString();
        }
        eventTrigger.inputParams = new object[] { rowData.GetString("username") };
        EventDelegate.Set(eventTrigger.onClick, delegate() { EventShowUserInfo((string)eventTrigger.inputParams[0]); });
    }
 public void OnPlayerJoinRoom(string roomId, JSONObject userData) {
   if (this.roomId == roomId) {
     PlayerSlotScript playerSlot = GetAvailableSlot(userData.GetString("username"));
     playerSlot.Init(userData.GetString("username"), userData.GetString("displayName"), userData.GetLong("cash"), userData.GetString("avatar"));
   } else {
     Debug.LogError("Not in this room " + this.roomId + " | " + roomId);
   }
 }
示例#21
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 public virtual void VerifyHSInfo(JSONObject info, AppContext ctx)
 {
     NUnit.Framework.Assert.AreEqual("incorrect number of elements", 4, info.Length());
     VerifyHsInfoGeneric(info.GetString("hadoopVersionBuiltOn"), info.GetString("hadoopBuildVersion"
                                                                                ), info.GetString("hadoopVersion"), info.GetLong("startedOn"));
 }
示例#22
0
 /**
  * read maps packages list
  * @param maps a list of maps objects that will be read from JSON file
  * @param packagesArray packages array
  */
 private void readMapsPackages(List <MapDownloadResource> maps, JSONArray packagesArray)
 {
     for (int i = 0; i < packagesArray.Length(); i++)
     {
         JSONObject currentPackageObject = null;
         try
         {
             currentPackageObject = packagesArray.GetJSONObject(i);
         }
         catch (JSONException ex)
         {
             SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
         }
         if (currentPackageObject != null)
         {
             MapDownloadResource currentMap = new MapDownloadResource();
             try
             {
                 currentMap.Code = (currentPackageObject.GetString(PACKAGE_CODE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSubType(GetMapType(currentPackageObject.GetInt(TYPE_ID)));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 JSONArray currentMapNames = currentPackageObject.GetJSONArray(LANGUAGES_ID);
                 if (currentMapNames != null)
                 {
                     for (int j = 0; j < currentMapNames.Length(); j++)
                     {
                         JSONObject currentMapNameObject = currentMapNames.GetJSONObject(j);
                         if (currentMapNameObject != null)
                         {
                             String currentMapName = currentMapNameObject.GetString(TL_NAME_ID);
                             if (currentMapName != null)
                             {
                                 currentMap.setName(currentMapName, currentMapNameObject.GetString(LNG_CODE_ID));
                             }
                         }
                     }
                 }
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 JSONObject currentMapBoundingBox = currentPackageObject.GetJSONObject(BBOX_ID);
                 if (currentMapBoundingBox != null)
                 {
                     currentMap.setBbLatMax(currentMapBoundingBox.GetDouble(LAT_MAX_ID));
                     currentMap.setBbLatMin(currentMapBoundingBox.GetDouble(LAT_MIN_ID));
                     currentMap.setBbLongMax(currentMapBoundingBox.GetDouble(LONG_MAX_ID));
                     currentMap.setBbLongMin(currentMapBoundingBox.GetDouble(LONG_MIN_ID));
                 }
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSkmFileSize(currentPackageObject.GetLong(SKM_SIZE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSkmFilePath(currentPackageObject.GetString(FILE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setZipFilePath(currentPackageObject.GetString(NB_ZIP_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setUnzippedFileSize(currentPackageObject.GetLong(UNZIP_SIZE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 JSONObject currentMapTXGDetails = currentPackageObject.GetJSONObject(TEXTURE_ID);
                 if (currentMapTXGDetails != null)
                 {
                     currentMap.setTXGFilePath(currentMapTXGDetails.GetString(TEXTURES_BIG_FILE_ID));
                     currentMap.setTXGFileSize(currentMapTXGDetails.GetLong(SIZE_BIG_FILE_ID));
                 }
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             try
             {
                 currentMap.setSkmAndZipFilesSize(currentPackageObject.GetLong(SIZE_ID));
             }
             catch (JSONException ex)
             {
                 SKLogging.WriteLog(TAG, ex.Message, SKLogging.LogDebug);
             }
             if ((currentMap.Code != null) && (currentMap.getSubType() != null))
             {
                 removeNullValuesIfExist(currentMap);
                 maps.Add(currentMap);
             }
         }
     }
 }
示例#23
0
 public static long getLong(this JSONObject json, string name)
 {
     return(json.GetLong(name));
 }
示例#24
0
    public void EventViewMessage(JSONObject message)
    {
        selectMessage = message;
        Utils.SetActive(scrollview.gameObject, false);
        Utils.SetActive(viewMessagePanel, true);
        Utils.SetActive(btnBack.gameObject, true);
        messageTitle.text   = message.GetString("title");
        messageContent.text = message.GetString("message");
        int goldVal = message.GetInt("goldVal");
        int gemVal  = message.GetInt("gemVal");

        if (goldVal <= 0 && gemVal <= 0)
        {
            Utils.SetActive(goldObject, false);
            Utils.SetActive(gemObject, false);
            EventDelegate.Set(btnClaim.onClick, delegate() {});
            Utils.SetActive(btnClaim.gameObject, false);
        }
        else
        {
            Utils.SetActive(goldObject, goldVal > 0);
            Utils.SetActive(gemObject, gemVal > 0);
            goldLabel.text = goldVal.ToString("N0");
            gemLabel.text  = gemVal.ToString("N0");
            rewardTable.Reposition();
            Utils.SetActive(btnClaim.gameObject, true);
            EventDelegate.Set(btnClaim.onClick, delegate() { ClaimReward(message.GetInt("type"), message.GetLong("createdAt"), message.GetString("fromUsername")); });
        }
    }
 public void OnPlayerJoinRoom(string roomId, JSONObject userData)
 {
     if (this.roomId == roomId)
     {
         PlayerSlotScript playerSlot = GetAvailableSlot(userData.GetString("username"));
         playerSlot.Init(userData.GetString("username"), userData.GetString("displayName"), userData.GetLong("cash"), userData.GetString("avatar"));
     }
     else
     {
         Debug.LogError("Not in this room " + this.roomId + " | " + roomId);
     }
 }
示例#26
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 public virtual void VerifyAMInfo(JSONObject info, AppContext ctx)
 {
     NUnit.Framework.Assert.AreEqual("incorrect number of elements", 5, info.Length());
     VerifyAMInfoGeneric(ctx, info.GetString("appId"), info.GetString("user"), info.GetString
                             ("name"), info.GetLong("startedOn"), info.GetLong("elapsedTime"));
 }
  void ClaimDailyRewardSuccess(JSONObject data) {
    ErrorCode.USER errorCode = (ErrorCode.USER)data.GetInt("errorCode");
    if (errorCode == ErrorCode.USER.NULL) {
      Debug.Log("ClaimDailyRewardSuccess-- " + data.ToString());
			AccountManager.Instance.lastClaimedDaily = data.GetLong("lastDaily");
			AccountManager.Instance.UpdateUserCash(data.GetLong("cash"));
			if (ScreenManager.Instance.SelectGameScreen != null) {
				ScreenManager.Instance.SelectGameScreen.ClaimedDailyRewardCallback();
			}
    } else {
      Debug.Log("ClaimDailyRewardFail-- " + data.ToString());
      HUDManager.Instance.AddFlyText(errorCode.ToString(), Vector3.zero, 40, Color.red);
    }
  }
示例#28
0
	public void EventViewMessage(JSONObject message) {
		selectMessage = message;
		Utils.SetActive(scrollview.gameObject, false);
		Utils.SetActive(viewMessagePanel, true);
		Utils.SetActive(btnBack.gameObject, true);
		messageTitle.text = message.GetString("title");
		messageContent.text = message.GetString("message");
		int goldVal = message.GetInt("goldVal");
		int gemVal = message.GetInt("gemVal");
		if (goldVal <= 0 && gemVal <= 0) {
			Utils.SetActive(goldObject, false);
			Utils.SetActive(gemObject, false);
	    EventDelegate.Set(btnClaim.onClick, delegate() {});
			Utils.SetActive(btnClaim.gameObject, false);
		} else {
			Utils.SetActive(goldObject, goldVal > 0);
			Utils.SetActive(gemObject, gemVal > 0);
			goldLabel.text = goldVal.ToString("N0");
			gemLabel.text = gemVal.ToString("N0");
			rewardTable.Reposition();
			Utils.SetActive(btnClaim.gameObject, true);
	    EventDelegate.Set(btnClaim.onClick, delegate() { ClaimReward(message.GetInt("type"), message.GetLong("createdAt"), message.GetString("fromUsername")); });
		}
	}
            private void Update(Context context, Conversation conversation, IMessage message)
            {
                string messagesString = mMessages.GetString(conversation.Id.ToString(), null);

                if (messagesString == null)
                {
                    return;
                }

                // Get current notification texts
                IDictionary <long, string> positionText = new Dictionary <long, string>();

                try {
                    JSONObject messagesJson = new JSONObject(messagesString);
                    IIterator  iterator     = messagesJson.Keys();
                    while (iterator.HasNext)
                    {
                        string     messageId   = (string)iterator.Next();
                        JSONObject messageJson = messagesJson.GetJSONObject(messageId);
                        long       position    = messageJson.GetLong(KEY_POSITION);
                        string     text        = messageJson.GetString(KEY_TEXT);
                        positionText[position] = text;
                    }
                } catch (JSONException e) {
                    if (Util.Log.IsLoggable(Util.Log.ERROR))
                    {
                        Util.Log.e(e.Message, e);
                    }
                    return;
                }

                // Sort by message position
                List <long> positions = new List <long>(positionText.Keys);

                positions.Sort();

                // Construct notification
                string conversationTitle = AtlasUtil.GetConversationTitle(App.GetLayerClient(), App.GetParticipantProvider(), conversation);

                NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle().SetBigContentTitle(conversationTitle);
                int i;

                if (positions.Count <= MAX_MESSAGES)
                {
                    i = 0;
                    inboxStyle.SetSummaryText((string)null);
                }
                else
                {
                    i = positions.Count - MAX_MESSAGES;
                    inboxStyle.SetSummaryText(context.GetString(Resource.String.notifications_num_more, i));
                }
                while (i < positions.Count)
                {
                    inboxStyle.AddLine(positionText[positions[i++]]);
                }

                string collapsedSummary = positions.Count == 1 ? positionText[positions[0]] :
                                          context.GetString(Resource.String.notifications_new_messages, positions.Count);

                // Construct notification
                // TODO: use large icon based on avatars
                var mBuilder = new NotificationCompat.Builder(context)
                               .SetSmallIcon(Resource.Drawable.notification)
                               .SetContentTitle(conversationTitle)
                               .SetContentText(collapsedSummary)
                               .SetAutoCancel(true)
                               .SetLights(ContextCompat.GetColor(context, Resource.Color.atlas_action_bar_background), 100, 1900)
                               .SetPriority(NotificationCompat.PriorityHigh)
                               .SetDefaults(NotificationCompat.DefaultSound | NotificationCompat.DefaultVibrate)
                               .SetStyle(inboxStyle);

                // Intent to launch when clicked
                Intent clickIntent = new Intent(context, typeof(MessagesListActivity))
                                     .SetPackage(context.ApplicationContext.PackageName)
                                     .PutExtra(LAYER_CONVERSATION_KEY, conversation.Id)
                                     .PutExtra(LAYER_MESSAGE_KEY, message.Id)
                                     .SetFlags(ActivityFlags.ClearTop);
                PendingIntent clickPendingIntent = PendingIntent.GetActivity(
                    context, Interlocked.Increment(ref sPendingIntentCounterFlag),
                    clickIntent, PendingIntentFlags.OneShot);

                mBuilder.SetContentIntent(clickPendingIntent);

                // Intent to launch when swiped out
                Intent cancelIntent = new Intent(ACTION_CANCEL)
                                      .SetPackage(context.ApplicationContext.PackageName)
                                      .PutExtra(LAYER_CONVERSATION_KEY, conversation.Id)
                                      .PutExtra(LAYER_MESSAGE_KEY, message.Id);
                PendingIntent cancelPendingIntent = PendingIntent.GetBroadcast(
                    context, Interlocked.Increment(ref sPendingIntentCounterFlag),
                    cancelIntent, PendingIntentFlags.OneShot);

                mBuilder.SetDeleteIntent(cancelPendingIntent);

                // Show the notification
                mManager.Notify(conversation.Id.ToString(), MESSAGE_ID, mBuilder.Build());
            }
示例#30
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 public static void VerifyHsJobPartial(JSONObject info, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                                       job)
 {
     NUnit.Framework.Assert.AreEqual("incorrect number of elements", 12, info.Length()
                                     );
     // everyone access fields
     VerifyHsJobGeneric(job, info.GetString("id"), info.GetString("user"), info.GetString
                            ("name"), info.GetString("state"), info.GetString("queue"), info.GetLong("startTime"
                                                                                                     ), info.GetLong("finishTime"), info.GetInt("mapsTotal"), info.GetInt("mapsCompleted"
                                                                                                                                                                          ), info.GetInt("reducesTotal"), info.GetInt("reducesCompleted"));
 }