GuildMemberState() public static method

Sends GuildMemberState to client.
public static GuildMemberState ( MsgrClient client, Guild guild, GuildMember member, Aura.Msgr.Database.User user, ContactStatus status ) : void
client MsgrClient
guild Guild
member Aura.Shared.Database.GuildMember
user Aura.Msgr.Database.User
status ContactStatus
return void
Ejemplo n.º 1
0
        public void FriendListRequest(MsgrClient client, Packet packet)
        {
            var user = client.User;

            // Lists are sorted alphabetically by the client
            var groups  = MsgrServer.Instance.Database.GetGroups(user);
            var friends = MsgrServer.Instance.Database.GetFriends(user);

            user.Groups.Clear();
            foreach (var group in groups)
            {
                user.Groups.Add(group.Id);
            }

            user.Friends.Clear();
            user.Friends.AddRange(friends);

            Send.GroupList(client, groups);
            Send.FriendListRequestR(client, friends);

            // Notify friends about user going online
            var friendUsers = MsgrServer.Instance.UserManager.Get(user.GetNormalFriendIds());

            if (friendUsers.Count != 0)
            {
                Send.FriendOnline(friendUsers, user);
            }

            // Notify user about online friends
            friendUsers = MsgrServer.Instance.UserManager.Get(user.GetFriendIds());
            foreach (var friendUser in friendUsers.Where(a => a.GetFriendshipStatus(user.Id) == FriendshipStatus.Normal))
            {
                Send.FriendOnline(client.User, friendUser);
            }

            // Notify guild members
            var guild = MsgrServer.Instance.GuildManager.FindGuildWithMember(user.CharacterId);

            if (guild != null)
            {
                var member = guild.GetMember(user.CharacterId);
                GuildManager.ForOnlineMembers(guild, memberUser => Send.GuildMemberState(memberUser.Client, guild, member, user, user.Status));
            }
        }
Ejemplo n.º 2
0
        public void ChangeOptions(MsgrClient client, Packet packet)
        {
            var nickname    = packet.GetString();
            var status      = (ContactStatus)packet.GetByte();
            var chatOptions = (ChatOptions)packet.GetUInt();

            var user = client.User;

            // Check nickname
            if (nickname.Length > 50)
            {
                Log.Warning("User '{0}' tried to use a nickname that's longer than 50 characters.", user.AccountId);
                Send.ChangeOptionsR(client, false);
                return;
            }

            // Check status
            if (!Enum.IsDefined(typeof(ContactStatus), status))
            {
                Log.Warning("User '{0}' tried to use an invalid or unknown status ({1}).", user.AccountId, status);
                Send.ChangeOptionsR(client, false);
                return;
            }

            // Check options
            if (!Enum.IsDefined(typeof(ChatOptions), chatOptions))
            {
                Log.Warning("User '{0}' tried to use a invalid or unknown options ({1}).", user.AccountId, chatOptions);
                Send.ChangeOptionsR(client, false);
                return;
            }

            var prevStatus = user.Status;

            // Change options
            user.Nickname    = nickname;
            user.Status      = status;
            user.ChatOptions = chatOptions;

            MsgrServer.Instance.Database.SaveOptions(user);

            Send.ChangeOptionsR(client, true);

            // Notify guild members
            if (prevStatus != status)
            {
                var guild = MsgrServer.Instance.GuildManager.FindGuildWithMember(user.CharacterId);
                if (guild != null)
                {
                    var member = guild.GetMember(user.CharacterId);
                    GuildManager.ForOnlineMembers(guild, memberUser => Send.GuildMemberState(memberUser.Client, guild, member, user, status));
                }
            }

            // Update friends
            var friendUsers = MsgrServer.Instance.UserManager.Get(user.GetNormalFriendIds());

            if (friendUsers.Count == 0)
            {
                return;
            }

            // Set offline if prev was not offline, set online if prev was offline,
            // and just update the options if not offline.
            if (prevStatus != ContactStatus.Offline && status == ContactStatus.Offline)
            {
                Send.FriendOffline(friendUsers, user);
            }
            else if (prevStatus == ContactStatus.Offline && status != ContactStatus.Offline)
            {
                Send.FriendOnline(friendUsers, user);
            }
            else if (status != ContactStatus.Offline)
            {
                Send.FriendOptionChanged(friendUsers, user);
            }
        }