コード例 #1
0
ファイル: Friends.cs プロジェクト: EEmulator/EEmulator
        private void AnswerInvitation(string senderName, bool accept, Callback <string> successCallback,
                                      Callback <InvitationError> errorCallback)
        {
            InvitationHelper.GetInvitation(this.client.BigDB, InvitationType.Friend,
                                           senderName, this.name, invitation =>
            {
                if (!invitation.Exists)
                {
                    errorCallback(InvitationError.InvitationNotFound);
                    return;
                }

                CommonPlayer.GetId(this.client.BigDB, senderName, senderId =>
                {
                    if (senderId == null)
                    {
                        InvitationHelper.DeleteInvitation(this.client.BigDB, InvitationType.Friend, senderName,
                                                          this.name, result =>
                                                          errorCallback(InvitationError.PlayerNotFound));
                        return;
                    }

                    this.GetFriendsCount(numFriends =>
                    {
                        if (accept)
                        {
                            if (numFriends >= this.MaxFriendsAllowed)
                            {
                                errorCallback(InvitationError.LimitReached);
                                return;
                            }

                            invitation.Status = InvitationStatus.Accepted;
                            this.AddOrRemoveFriend(senderId, true);
                        }
                        else
                        {
                            invitation.Status = InvitationStatus.Rejected;
                        }

                        invitation.Save(() => successCallback(senderId));
                    });
                });
            });
        }
コード例 #2
0
ファイル: CrewLobby.cs プロジェクト: EEmulator/EEmulator
        private void InviteMember(BasePlayer player, string username, Callback successCallback,
                                  Callback <InvitationError> errorCallback)
        {
            if (!this.crew.HasPower(player, CrewPower.MembersManagement))
            {
                errorCallback(InvitationError.NotAllowed);
                return;
            }

            this.crew.GetMembers(members =>
            {
                if (members.Count >= 25)
                {
                    errorCallback(InvitationError.LimitReached);
                    return;
                }

                var member = members.FirstOrDefault(it => it.Name == username);
                if (member != null)
                {
                    errorCallback(InvitationError.AlreadyAdded);
                    return;
                }

                CommonPlayer.GetId(this.PlayerIO.BigDB, username, userId =>
                {
                    if (userId == null)
                    {
                        errorCallback(InvitationError.PlayerNotFound);
                        return;
                    }

                    InvitationHelper.GetInvitation(this.PlayerIO.BigDB, InvitationType.Crew,
                                                   this.crewId, username, oldInvitation =>
                    {
                        if (oldInvitation.Exists)
                        {
                            errorCallback(InvitationError.AlreadySent);
                            return;
                        }

                        InvitationBlocking.IsCrewBlocked(this.PlayerIO.BigDB, username, this.crewId, blocked =>
                        {
                            if (blocked)
                            {
                                errorCallback(InvitationError.Blocked);
                                return;
                            }

                            var newInvitation = new DatabaseObject();
                            newInvitation.Set("Sender", this.crewId);
                            newInvitation.Set("Recipient", username);
                            newInvitation.Set("Status", (int)InvitationStatus.Pending);

                            InvitationHelper.CreateInvitation(this.PlayerIO.BigDB, InvitationType.Crew,
                                                              this.crewId, username,
                                                              invitation => successCallback());
                        });
                    });
                });
            });
        }
コード例 #3
0
ファイル: CrewLobby.cs プロジェクト: EEmulator/EEmulator
        public override void GotMessage(CommonPlayer player, Message message)
        {
            if (!this.initialized)
            {
                this.queue.Add(new QueueItem(player, message));
                this.ProcessQueue();
                return;
            }

            if (message.Type == "getCrew")
            {
                this.crew.SendGetMessage(player);
                return;
            }

            if (player.IsGuest)
            {
                return;
            }

            switch (message.Type)
            {
            case "swapUsers":
            {
                if (player.ConnectUserId != "merge")
                {
                    break;
                }

                this.crew.SwapMembers(message.GetString(0), message.GetString(1), () => player.Send(message.Type));
                break;
            }

            case "subscribe":
            {
                if (crew.isContest)
                {
                    this.SendErrorReply(Message.Create(message.Type), player, "Subscribing to contest crews is disabled.");
                    return;
                }
                if (this.crewId == "everybodyeditsstaff")
                {
                    break;
                }

                NotificationHelper.AddSubscription(this.PlayerIO.BigDB, player.ConnectUserId, "crew" + this.crewId,
                                                   subscribed =>
                    {
                        if (subscribed)
                        {
                            this.crew.Subscribers++;
                            this.crew.Save();
                        }
                        player.Send(message.Type, this.crew.Subscribers);
                    });
                break;
            }

            case "unsubscribe":
            {
                if (this.crewId == "everybodyeditsstaff")
                {
                    break;
                }

                NotificationHelper.RemoveSubscription(this.PlayerIO.BigDB, player.ConnectUserId,
                                                      "crew" + this.crewId,
                                                      unsubscribed =>
                    {
                        if (unsubscribed)
                        {
                            if (crew.Subscribers > 0)
                            {
                                this.crew.Subscribers--;
                                this.crew.Save();
                            }
                        }
                        player.Send(message.Type, this.crew.Subscribers);
                    });
                break;
            }

            case "answerInvite":
            {
                if (crew.isContest)
                {
                    this.SendErrorReply(Message.Create(message.Type), player, "Joining is disabled for contest crews.");
                    return;
                }
                var accept = message.GetBoolean(0);

                InvitationHelper.GetInvitation(this.PlayerIO.BigDB, InvitationType.Crew,
                                               this.crewId, player.Name, invitation =>
                    {
                        var rtn = Message.Create(message.Type);

                        if (!invitation.Exists)
                        {
                            this.SendErrorReply(rtn, player, "Crew invite not found.");
                            return;
                        }
                        if (invitation.Status != InvitationStatus.Pending)
                        {
                            this.SendErrorReply(rtn, player, "Invitation already answered.");
                            return;
                        }
                        if (crew.IsMember(player))
                        {
                            this.SendErrorReply(rtn, player, "Already member of crew.");
                            return;
                        }

                        this.PlayerIO.BigDB.Load("CrewMembership", player.ConnectUserId, membership =>
                        {
                            if (accept)
                            {
                                if (membership != null && membership.Count >= 10)
                                {
                                    this.SendErrorReply(rtn, player, "You can't be in more than 10 crews.");
                                    return;
                                }

                                invitation.Status = InvitationStatus.Accepted;
                                crew.AddMember(player);
                            }
                            else
                            {
                                invitation.Status = InvitationStatus.Rejected;
                            }

                            rtn.Add(true);
                            invitation.Save(() => player.Send(rtn));
                        });
                    });
                break;
            }
            }

            if (!this.crew.IsMember(player))
            {
                return;
            }

            switch (message.Type)
            {
            case "setMemberInfo":
            {
                var username = message.GetString(0).ToLower();
                var about    = message.GetString(1);
                if (about.Length > 100)
                {
                    about = about.Substring(100);
                }

                this.SetMemberInfo(Message.Create(message.Type), player, username, about);
                break;
            }

            case "setMemberRank":
            {
                var username = message.GetString(0).ToLower();
                var rank     = message.GetInt(1);

                this.SetMemberRank(Message.Create(message.Type), player, username, rank);
                break;
            }

            case "editRank":
            {
                var rankId = message.GetInt(0);
                var name   = message.GetString(1).Trim();
                var powers = message.GetString(2);

                this.EditRank(Message.Create(message.Type), player, rankId, name, powers);
                break;
            }

            case "removeMember":
            {
                if (crew.isContest)
                {
                    this.SendErrorReply(Message.Create(message.Type), player, "Removing members is disabled for contest crews.");
                    return;
                }
                var username = message.GetString(0).ToLower();

                this.RemoveMember(Message.Create(message.Type), player, username);
                break;
            }

            case "leaveCrew":
            {
                if (crew.isContest)
                {
                    this.SendErrorReply(Message.Create(message.Type), player, "Leaving the crew is disabled for contest crews.");
                    return;
                }

                if (crew.IsMember(player) && !crew.GetRank(player).IsOwner)
                {
                    crew.DatabaseObject.GetObject("Members").Remove(player.ConnectUserId);
                    this.PlayerIO.BigDB.LoadOrCreate("CrewMembership", player.ConnectUserId, membership =>
                        {
                            membership.Remove(this.crewId);
                            membership.Save();
                            this.crew.Save();
                            player.Send(message.Type);
                            player.Disconnect();
                        });
                }
                break;
            }

            case "inviteMember":
            {
                if (crew.isContest)
                {
                    this.SendErrorReply(Message.Create(message.Type), player, "Inviting members is disabled for contest crews.");
                    return;
                }

                var username = message.GetString(0).ToLower();

                this.InviteMember(player, username,
                                  () => player.Send(message.Type, true),
                                  error =>
                    {
                        switch (error)
                        {
                        case InvitationError.AlreadyAdded:
                            {
                                player.Send(message.Type, false,
                                            "This user is already a member of this crew.");
                                break;
                            }

                        case InvitationError.AlreadySent:
                            {
                                player.Send(message.Type, false,
                                            "This user already has a pending invitation.");
                                break;
                            }

                        case InvitationError.PlayerNotFound:
                            {
                                player.Send(message.Type, false,
                                            "Unknown user. Please check your spelling.");
                                break;
                            }

                        case InvitationError.Blocked:
                            {
                                player.Send(message.Type, false,
                                            "This user is blocking all crew invitations.");
                                break;
                            }

                        case InvitationError.NotAllowed:
                            {
                                player.Send(message.Type, false,
                                            "You have not been given rights to invite new members to this crew.");
                                break;
                            }

                        case InvitationError.LimitReached:
                            {
                                player.Send(message.Type, false,
                                            "Crew members limit reached.");
                                break;
                            }

                        default:
                            {
                                player.Send(message.Type, false,
                                            "Something went wrong. Try again later.");
                                break;
                            }
                        }
                    });
                break;
            }

            case "deleteInvite":
            {
                var recipientName = message.GetString(0).ToLower();

                if (!crew.HasPower(player, CrewPower.MembersManagement))
                {
                    player.Send(message.Type, false);
                }
                else
                {
                    InvitationHelper.DeleteInvitation(this.PlayerIO.BigDB, InvitationType.Crew,
                                                      this.crewId, recipientName, success =>
                        {
                            if (!success)
                            {
                                this.PlayerIO.ErrorLog.WriteError(
                                    "Error deleting crew invitation from " + this.crewId + " to " +
                                    recipientName, "Invite not found",
                                    "Error deleting pending invitation", null);
                            }
                            player.Send(message.Type, success);
                        });
                }
                break;
            }

            case "getPendingInvites":
            {
                if (!crew.HasPower(player, CrewPower.MembersManagement))
                {
                    player.Send(message.Type, false);
                }
                else
                {
                    InvitationHelper.GetInvitationsFrom(this.PlayerIO.BigDB, InvitationType.Crew,
                                                        this.crewId, invites =>
                        {
                            var rtn = Message.Create(message.Type);
                            rtn.Add(true);
                            foreach (var invite in invites)
                            {
                                rtn.Add(invite.Recipient);
                                rtn.Add((int)invite.Status);
                            }
                            player.Send(rtn);
                        });
                }
                break;
            }

            case "sendAlert":
            {
                if (!this.crew.HasPower(player, CrewPower.AlertSending))
                {
                    player.Send(message.Type, "You don't have rights to send alerts from this crew.");
                    break;
                }

                var text = message.GetString(0).Trim();
                if (text.Length > 140)
                {
                    text = text.Substring(0, 140);
                }

                this.crew.PublishNotification(text, notification =>
                    {
                        player.Send("info", "Success", "Alert sent to all crew subscribers.");
                        player.Send(message.Type);
                    });
                break;
            }

            case "setColors":
            {
                if (!this.crew.HasPower(player, CrewPower.ProfileCustomization))
                {
                    break;
                }

                if (!this.crew.Unlocked("ColorPick"))
                {
                    break;
                }

                this.crew.TextColor      = message.GetUInt(0);
                this.crew.PrimaryColor   = message.GetUInt(1);
                this.crew.SecondaryColor = message.GetUInt(2);
                this.crew.SetUnlocked("ColorPick", false);

                this.crew.Save();
                break;
            }

            case "setFaceplate":
            {
                if (!this.crew.HasPower(player, CrewPower.ProfileCustomization))
                {
                    break;
                }

                var id    = message.GetString(0).ToLower();
                var color = message.GetInt(1);

                if ((id != "none" && id != "" && !this.crew.Faceplates.Contains(id)) || color < 0 || color > 9)
                {
                    break;
                }

                if (id == "none")
                {
                    id = "";
                }

                this.crew.Faceplate      = id;
                this.crew.FaceplateColor = color;
                this.crew.Save();
                break;
            }

            case "disband":
            {
                if (crew.isContest)
                {
                    this.SendErrorReply(Message.Create(message.Type), player, "Disbanding the crew is disabled for contest crews.");
                    return;
                }

                if (!this.crew.GetRank(player).IsOwner)
                {
                    break;
                }

                // Cleanup membership of all members
                var members = this.crew.DatabaseObject.GetObject("Members").Properties.ToArray();
                this.PlayerIO.BigDB.LoadKeys("CrewMembership", members, membership =>
                    {
                        foreach (var m in membership.Where(m => m != null))
                        {
                            m.Remove(this.crewId);
                            m.Save();
                        }
                    });

                // Cleanup all pending invitations. People can't join here anymore
                InvitationHelper.GetInvitationsFrom(this.PlayerIO.BigDB, InvitationType.Crew,
                                                    this.crewId, invites => { InvitationHelper.DeleteInvitations(this.PlayerIO.BigDB, invites); });

                // Consume one "crew" PayVault item to allow user to buy another crew since this one is no longer active
                player.PayVault.Refresh(() =>
                    {
                        var crewItem = player.PayVault.First("crew");
                        if (crewItem != null)
                        {
                            player.PayVault.Consume(new[] { crewItem }, this.SetAsInvalid,
                                                    error => { this.SetAsInvalid(); });
                        }
                        else
                        {
                            this.SetAsInvalid();
                        }
                    });

                // Delete the crew object
                this.crew.Disband();

                player.Send(message.Type);

                break;
            }

            default:
            {
                this.shop.GotMessage(player, message);
                break;
            }
            }
        }
コード例 #4
0
        public void HandleMessage(LobbyPlayer player, Message m)
        {
            var rtn = Message.Create(m.Type);

            switch (m.Type)
            {
            case "getCrew":
            {
                this.LoadCrew(Regex.Replace(m.GetString(0), @"\s+", "").ToLower(),
                              crew => crew.SendGetMessage(player));
                break;
            }

            case "getMyCrews":
            {
                this.GetMyCrews(rtn, player);
                break;
            }

            case "createCrew":
            {
                this.CreateCrew(rtn, player, m.GetString(0).Trim());
                break;
            }

            case "getCrewInvites":
            {
                InvitationHelper.GetInvitationsTo(this.client.BigDB, InvitationType.Crew,
                                                  player.Name, invites =>
                    {
                        var invitesIds =
                            invites.Where(it => it.Status == InvitationStatus.Pending)
                            .Select(it => it.Sender)
                            .ToArray();
                        if (invitesIds.Length > 0)
                        {
                            this.client.BigDB.LoadKeys("Crews", invitesIds, crews =>
                            {
                                foreach (var crew in crews.Where(crew => crew != null))
                                {
                                    rtn.Add(crew.Key);
                                    rtn.Add(crew.GetString("Name"));
                                    rtn.Add(crew.GetString("LogoWorld", ""));
                                }

                                player.Send(rtn);
                            });
                        }
                        else
                        {
                            player.Send(rtn);
                        }
                    });
                break;
            }

            case "blockCrewInvites":
            {
                var crewId      = m.GetString(0).ToLower();
                var shouldBlock = m.GetBoolean(1);

                InvitationBlocking.BlockCrew(this.client.BigDB, player.ConnectUserId, crewId, shouldBlock, () =>
                    {
                        if (shouldBlock)
                        {
                            InvitationHelper.GetInvitation(this.client.BigDB, InvitationType.Crew, crewId, player.Name,
                                                           invitation =>
                            {
                                if (invitation.Exists)
                                {
                                    invitation.Status = InvitationStatus.Rejected;
                                    invitation.Save(() => player.Send(m.Type, true));
                                }
                                else
                                {
                                    player.Send(m.Type, true);
                                }
                            });
                        }
                        else
                        {
                            player.Send(m.Type, true);
                        }
                    });
                break;
            }

            case "blockAllCrewInvites":
            {
                var shouldBlock = m.GetBoolean(0);

                InvitationBlocking.BlockAllCrews(this.client.BigDB, player.ConnectUserId, shouldBlock);
                player.Send(m.Type, shouldBlock);
                break;
            }
            }
        }
コード例 #5
0
ファイル: Friends.cs プロジェクト: EEmulator/EEmulator
        private void CreateInvitation(string recipientName,
                                      Callback successCallback, Callback <InvitationError> errorCallback)
        {
            if (this.name == recipientName)
            {
                errorCallback(InvitationError.SendingToSelf);
                return;
            }

            CommonPlayer.GetId(this.client.BigDB, recipientName, recipientId =>
            {
                if (recipientId == null)
                {
                    errorCallback(InvitationError.PlayerNotFound);
                    return;
                }

                this.GetFriendKeys(this.connectUserId, friends =>
                {
                    if (friends.Contains(recipientId))
                    {
                        errorCallback(InvitationError.AlreadyAdded);
                        return;
                    }

                    InvitationHelper.GetInvitation(this.client.BigDB, InvitationType.Friend,
                                                   this.name, recipientName, oldInvitation =>
                    {
                        if (oldInvitation.Exists)
                        {
                            errorCallback(InvitationError.AlreadySent);
                            return;
                        }

                        this.GetPendingInvitationsCount(pendingInvitationsCount =>
                        {
                            if (friends.Count + pendingInvitationsCount >= this.MaxFriendsAllowed)
                            {
                                errorCallback(InvitationError.LimitReached);
                                return;
                            }

                            InvitationHelper.GetInvitation(this.client.BigDB, InvitationType.Friend,
                                                           recipientName, this.name, invitationToMe =>
                            {
                                if (invitationToMe.Exists && invitationToMe.Status == InvitationStatus.Pending)
                                {
                                    invitationToMe.Status = InvitationStatus.Accepted;
                                    this.AddOrRemoveFriend(recipientId, true,
                                                           () => invitationToMe.Save(successCallback));
                                    return;
                                }

                                InvitationBlocking.IsUserBlocked(this.client.BigDB, recipientId, this.name,
                                                                 blocked =>
                                {
                                    if (blocked)
                                    {
                                        errorCallback(InvitationError.Blocked);
                                        return;
                                    }

                                    var newInvitation = new DatabaseObject();
                                    newInvitation.Set("Sender", this.name);
                                    newInvitation.Set("Recipient", recipientName);
                                    newInvitation.Set("Status", (int)InvitationStatus.Pending);

                                    InvitationHelper.CreateInvitation(this.client.BigDB,
                                                                      InvitationType.Friend,
                                                                      this.name, recipientName,
                                                                      invitation => successCallback());
                                });
                            });
                        });
                    });
                });
            });
        }
コード例 #6
0
ファイル: Friends.cs プロジェクト: EEmulator/EEmulator
        public void ProcessMessages(QueueItem item, LobbyPlayer player)
        {
            switch (item.Method)
            {
            case "getFriends":
            {
                this.GetFriendKeys(player.ConnectUserId, keys =>
                    {
                        if (keys.Count <= 0)
                        {
                            player.Send(item.Method);
                            return;
                        }

                        OnlineStatus.GetOnlineStatus(this.client, keys.ToArray(), status =>
                        {
                            var rtn = Message.Create(item.Method);
                            foreach (var stat in status.Where(stat => stat != null))
                            {
                                stat.ToMessage(rtn);
                            }
                            player.Send(rtn);
                        });
                    });
                break;
            }

            case "getPending":
            {
                InvitationHelper.GetInvitationsFrom(this.client.BigDB, InvitationType.Friend,
                                                    this.name, invites =>
                    {
                        var rtn = Message.Create(item.Method);
                        foreach (var invite in invites)
                        {
                            rtn.Add(invite.Recipient);
                            rtn.Add((int)invite.Status);
                        }
                        player.Send(rtn);
                    });
                break;
            }

            case "getInvitesToMe":
            {
                InvitationHelper.GetInvitationsTo(this.client.BigDB, InvitationType.Friend,
                                                  this.name, invites =>
                    {
                        var rtn = Message.Create(item.Method);
                        foreach (var invite in invites.Where(it => it.Status == InvitationStatus.Pending))
                        {
                            rtn.Add(invite.Sender);
                        }
                        player.Send(rtn);
                    });
                break;
            }

            case "getBlockedUsers":
            {
                InvitationBlocking.GetBlockedUsers(this.client.BigDB, this.connectUserId, blockedUsers =>
                    {
                        var rtn = Message.Create(item.Method);
                        foreach (var blockedUser in blockedUsers)
                        {
                            rtn.Add(blockedUser);
                        }
                        player.Send(rtn);
                    });
                break;
            }

            case "createInvite":
            {
                if (!player.HasFriendFeatures)
                {
                    player.Send(item.Method, false);
                    return;
                }

                var friendName = item.Message.GetString(0).ToLower();

                this.CreateInvitation(friendName,
                                      () => player.Send(item.Method, true),
                                      error =>
                    {
                        switch (error)
                        {
                        case InvitationError.PlayerNotFound:
                            {
                                player.Send(item.Method, false,
                                            "Unknown user. Please check your spelling.");
                                break;
                            }

                        case InvitationError.AlreadyAdded:
                            {
                                player.Send(item.Method, false,
                                            "This user is already on your friendslist!");
                                break;
                            }

                        case InvitationError.AlreadySent:
                            {
                                player.Send(item.Method, false,
                                            "You already have a pending invitation for this user.");
                                break;
                            }

                        case InvitationError.LimitReached:
                            {
                                player.Send(item.Method, false,
                                            "You cannot have more than " +
                                            this.MaxFriendsAllowed +
                                            " friends and invites.");
                                break;
                            }

                        case InvitationError.Blocked:
                            {
                                player.Send(item.Method, false,
                                            "This user is blocking friend requests.");
                                break;
                            }

                        case InvitationError.SendingToSelf:
                            {
                                player.Send(item.Method, false,
                                            "You cannot add yourself.");
                                break;
                            }
                        }
                    });
                break;
            }

            case "answerInvite":
            {
                if (!player.HasFriendFeatures)
                {
                    player.Send(item.Method, false);
                    return;
                }

                var invitedBy = item.Message.GetString(0).ToLower();
                var accept    = item.Message.GetBoolean(1);

                this.AnswerInvitation(invitedBy, accept,
                                      senderId =>
                    {
                        OnlineStatus.GetOnlineStatus(this.client, senderId, onlineStatus =>
                        {
                            var rtn = Message.Create(item.Method, true);
                            player.Send(onlineStatus.ToMessage(rtn));
                        });
                    },
                                      error =>
                    {
                        switch (error)
                        {
                        case InvitationError.PlayerNotFound:
                            {
                                player.Send(item.Method, false,
                                            "Sorry, the sender of this friend request does not exist.");
                                break;
                            }

                        case InvitationError.InvitationNotFound:
                            {
                                player.Send(item.Method, false,
                                            "Sorry, the friend request does not exist anymore.");
                                break;
                            }

                        case InvitationError.LimitReached:
                            {
                                player.Send(item.Method, false,
                                            "You cannot have more than " +
                                            this.MaxFriendsAllowed +
                                            " friends.");
                                break;
                            }
                        }
                    });
                break;
            }

            case "deleteInvite":
            {
                var recipientName = item.Message.GetString(0).ToLower();

                InvitationHelper.DeleteInvitation(this.client.BigDB, InvitationType.Friend,
                                                  this.name, recipientName, success =>
                    {
                        if (!success)
                        {
                            this.client.ErrorLog.WriteError(
                                "Error deleting invitation from " + player.Name + " to " +
                                recipientName, "Invite not found",
                                "Error deleting pending invitation", null);
                        }
                        player.Send(item.Method, success);
                    });
                break;
            }

            case "blockUserInvites":
            {
                var invitedByName = item.Message.GetString(0).ToLower();
                var shouldBlock   = item.Message.GetBoolean(1);

                InvitationBlocking.BlockUser(this.client.BigDB, this.connectUserId, invitedByName, shouldBlock,
                                             () =>
                    {
                        if (shouldBlock)
                        {
                            InvitationHelper.GetInvitation(this.client.BigDB, InvitationType.Friend, invitedByName,
                                                           this.name, invitation =>
                            {
                                if (invitation.Exists)
                                {
                                    invitation.Status = InvitationStatus.Rejected;
                                    invitation.Save(() => player.Send(item.Method, true));
                                }
                                else
                                {
                                    player.Send(item.Method, true);
                                }
                            });
                        }
                        else
                        {
                            player.Send(item.Method, true);
                        }
                    });
                break;
            }

            case "getBlockStatus":
            {
                InvitationBlocking.IsBlockingAllUsers(this.client.BigDB, this.connectUserId,
                                                      isBlocking => { player.Send(item.Method, isBlocking); });
                break;
            }

            case "blockAllInvites":
            {
                var shouldBlock = item.Message.GetBoolean(0);

                InvitationBlocking.BlockAllFriends(this.client.BigDB, this.connectUserId, shouldBlock);
                player.Send(item.Method, shouldBlock);
                break;
            }

            case "deleteFriend":
            {
                CommonPlayer.GetId(this.client.BigDB, item.Message.GetString(0).ToLower(), friendId =>
                    {
                        this.AddOrRemoveFriend(friendId, false,
                                               delegate { player.Send(item.Method, true); });
                    });
                break;
            }

            case "GetOnlineStatus":
            {
                var id = item.Message.Count > 0 ? item.Message.GetString(0) : player.ConnectUserId;
                OnlineStatus.GetOnlineStatus(this.client, id,
                                             onlineStatus => player.Send(onlineStatus.ToMessage(item.Method)));
                break;
            }
            }
        }