Exemple #1
0
        public static Task <DatabaseObject> LoadAsync(this BigDB bigDB, string table, string key)
        {
            var tcs = new TaskCompletionSource <DatabaseObject>();

            bigDB.Load(table, key, tcs.SetResult, tcs.SetException);
            return(tcs.Task);
        }
        private static void IsBlocked(BigDB bigDb, string blockingUser, string blockedId, string blockAllProp,
                                      string blockProp, Callback <bool> callback)
        {
            bigDb.Load(BlockingTable, blockingUser, blockingTable =>
            {
                if (blockingTable == null)
                {
                    callback(false);
                    return;
                }

                if (blockingTable.GetBool(blockAllProp, false))
                {
                    callback(true);
                    return;
                }

                var blockingObject = blockingTable.GetObject(blockProp);
                if (blockingObject == null)
                {
                    callback(false);
                    return;
                }

                callback(blockingObject.GetBool(blockedId, false));
            });
        }
Exemple #3
0
 public static void GetId(BigDB bigDb, string username, Callback <string> callback)
 {
     bigDb.Load("Usernames", username, name =>
     {
         if (name == null || name.GetString("owner", "none") == "none")
         {
             callback(null);
         }
         else
         {
             callback(name.GetString("owner"));
         }
     });
 }
 public static void GetSubscriptions(BigDB bigDb, string connectUserId, Callback <string[]> callback)
 {
     bigDb.Load("Subscriptions", connectUserId, obj =>
     {
         var defaultChannels = new[] { "news", "creweverybodyeditsstaff" };
         if (obj == null)
         {
             callback(defaultChannels);
         }
         else
         {
             var subs = (from sub in obj where (bool)sub.Value select sub.Key).Concat(defaultChannels).ToArray();
             callback(subs);
         }
     });
 }
        public void awardAchievement(Achievement achiev)
        {
            bigDB.Load("PlayerObjects", owner.ConnectUserId, delegate(DatabaseObject result) {
                DatabaseObject achievs = result.GetObject("Achievements");
                if (achievs.Contains(achiev.name))
                {
                    return;
                }

                DatabaseObject achievObject = new DatabaseObject();
                achievObject.Set("Date", DateTime.Now);
                owner.achievements.Set(achiev.name, achievObject);
                owner.awardXP(achiev.xpReward, achiev.shardReward);
                owner.PlayerObject.Save(true, delegate()
                {
                    owner.Send(MessageID.ACHIEVEMENT_UNLOCKED, achiev.Id, achiev.name, achiev.xpReward, achiev.shardReward);
                    achievements.Remove(achiev);
                });
            });
        }
        public static void GetDismissedNotifications(BigDB bigDb, string connectUserId, Action <string[]> callback)
        {
            bigDb.Load("Dismisses", connectUserId, obj =>
            {
                if (obj == null)
                {
                    callback(new string[] { });
                }
                else
                {
                    if (!obj.Contains("Notifications"))
                    {
                        obj.Set("Notifications", new DatabaseArray());
                    }
                    var notifications = obj.GetArray("Notifications");

                    callback(notifications.Select(i => i.ToString()).ToArray());
                }
            });
        }
        private static void GetBlocked(BigDB bigDb, string userId, string blockProp, Callback <List <string> > callback)
        {
            bigDb.Load(BlockingTable, userId, blockingTable =>
            {
                var rtn = new List <string>();
                if (blockingTable == null)
                {
                    callback(rtn);
                    return;
                }

                var blockingObject = blockingTable.GetObject(blockProp);
                if (blockingObject == null || blockingObject.Count == 0)
                {
                    callback(rtn);
                    return;
                }

                rtn.AddRange(from blockedUser in blockingObject where (bool)blockedUser.Value select blockedUser.Key);

                callback(rtn);
            });
        }
 public static void RemoveSubscription(BigDB bigDb, string connectUserId, string channel, Callback <bool> callback)
 {
     bigDb.Load("Subscriptions", connectUserId, obj =>
     {
         if (obj != null)
         {
             if (obj.GetBool(channel, false))
             {
                 obj.Set(channel, false);
                 obj.Save();
                 callback(true);
             }
             else
             {
                 callback(false);
             }
         }
         else
         {
             callback(false);
         }
     });
 }
 private static void IsBlockingAll(BigDB bigDb, string userId, string blockAllProp, Callback <bool> callback)
 {
     bigDb.Load(BlockingTable, userId,
                blockingTable => { callback(blockingTable != null && blockingTable.GetBool(blockAllProp, false)); });
 }