Ejemplo n.º 1
0
 public void Update()
 {
     while (requests.Count > 0)
     {
         DBCallback request = (DBCallback)requests.Dequeue();
         request.completedCallback(request);
     }
 }
Ejemplo n.º 2
0
	void getFriends (object obj)
	{
		lock (singletonLock)
		{
			try
			{
				Action<DBCallback> callback = (Action<DBCallback>)obj;

				List<FriendEntity> friends = new List<FriendEntity>();
				IEnumerable<FriendTable> dataTable = connection.Table<FriendTable>();

				foreach (FriendTable item in dataTable)
				{
					FriendEntity friend = new FriendEntity();
					friend.UserId = item.UserId;
					friend.Name = item.DisplayName;
					friend.Avatar = item.Avatar;
					friend.Gender = item.Gender;
					friend.Level = item.Level;
					friend.Score = item.Score;
					friend.FBId = item.FbId;

					friends.Add(friend);
			   } 
				DBCallback dbCallback = new DBCallback ();
				dbCallback.Data = friends;
				dbCallback.completedCallback = callback;
				DBCallbackDispatcher.Singleton.requests.Enqueue (dbCallback);
				Debug.Log("Completed: "+friends.Count);
			}
			catch(Exception ex)
			{
				Debug.LogWarning (ex.Message);
			}
		}
	}
Ejemplo n.º 3
0
	void getAccount (object obj)
	{
		lock (singletonLock)
		{
			try
			{
				Action<DBCallback> callback = (Action<DBCallback>)obj;
				AccountEntity  accountEntity = new AccountEntity ();
				IEnumerable<AcountTable> dataTable = connection.Table<AcountTable>();
				foreach (AcountTable item in dataTable)
				{
					string userId = Encryption.Decrypt (item.UserId);
					string userName = Encryption.Decrypt (item.UserName);
					string password = Encryption.Decrypt (item.Password);
					string accountType = Encryption.Decrypt (item.AccountType);
					
					try {
						accountEntity.UserId = userId;
						accountEntity.UserName = userName;
						accountEntity.Password = password;
						accountEntity.AccountType = accountType;						
					} catch (Exception ex) {
						Debug.LogException (ex);
					}
					break;
				}
				
				DBCallback dbCallback = new DBCallback ();
				dbCallback.Data = accountEntity;
				dbCallback.completedCallback = callback;
				DBCallbackDispatcher.Singleton.requests.Enqueue (dbCallback);
			}
			catch(Exception ex)
			{
				Debug.LogWarning (ex.Message);
			}
		}
	}
Ejemplo n.º 4
0
	void getSessionKey (object obj)
	{
		lock (singletonLock)
		{
			try
			{
				Action<DBCallback> callback = (Action<DBCallback>)obj;
				string sessionKey = "";
				IEnumerable<SessionTable> dataTable = connection.Table<SessionTable>();
				foreach (SessionTable item in dataTable)
				{
					sessionKey = Encryption.Decrypt (item.SessionKey);
					break;
				}
				
				DBCallback dbCallback = new DBCallback ();
				dbCallback.Data = sessionKey;
				dbCallback.completedCallback = callback;
				DBCallbackDispatcher.Singleton.requests.Enqueue (dbCallback);
			}
			catch(Exception ex)
			{
				Debug.LogWarning (ex.Message);
			}
		}
	}
Ejemplo n.º 5
0
	void getLevels (object obj)
	{
		try
		{
			Action<DBCallback> callback = (Action<DBCallback>)obj;
			Dictionary<int, LevelEntity> levels = new Dictionary<int, LevelEntity> ();
			IEnumerable<LevelTable> dataTable = connection.Table<LevelTable>();
			foreach (LevelTable item in dataTable)
			{
				LevelEntity levelEntity = new LevelEntity ();				
				string levelDecrypt = Encryption.Decrypt (item.Level);
				string scoreDecrypt = Encryption.Decrypt (item.Score);
				string rateDecrypt = Encryption.Decrypt (item.Rate);
				string replayDecrypt = Encryption.Decrypt (item.Replay);

				try {
					levelEntity.Level = Convert.ToInt32 (levelDecrypt);
					levelEntity.Score = Convert.ToInt32 (scoreDecrypt);
					levelEntity.Rate = Convert.ToInt32 (rateDecrypt);
					levelEntity.Replay = Convert.ToInt32 (replayDecrypt);
					
					// Add Score Entity to Score List
					levels[levelEntity.Level] = levelEntity;
				} catch (Exception ex) {
					Debug.LogException (ex);
				}
			}
			Debug.LogWarning("getLevels");
			DBCallback dbCallback = new DBCallback ();
			dbCallback.Data = levels;
			dbCallback.completedCallback = callback;
			DBCallbackDispatcher.Singleton.requests.Enqueue (dbCallback);
		}
		catch(Exception ex)
		{
			Debug.LogException (ex);
		}
	}