FriendOffline() public static method

Notifies users about friend being offline.
public static FriendOffline ( List users, Aura.Msgr.Database.User friend ) : void
users List
friend Aura.Msgr.Database.User
return void
コード例 #1
0
ファイル: MsgrHandlers.cs プロジェクト: anjhony6778/aura
        public void DeleteFriend(MsgrClient client, Packet packet)
        {
            var contactId = packet.GetInt();

            // Check friend
            var friend = client.User.GetFriend(contactId);

            if (friend == null)
            {
                Log.Warning("DeleteFriend: User '{0}' tried to delete non-existent friend.", client.User.AccountId);
                client.Kill();                 // Out of sync, close connection.
                return;
            }

            client.User.Friends.Remove(friend);
            MsgrServer.Instance.Database.DeleteFriend(client.User.Id, contactId);

            // Live update
            var friendUser = MsgrServer.Instance.UserManager.Get(contactId);

            if (friendUser != null)
            {
                Send.FriendOffline(friendUser, client.User);
            }
        }
コード例 #2
0
ファイル: MsgrHandlers.cs プロジェクト: anjhony6778/aura
        public void FriendBlock(MsgrClient client, Packet packet)
        {
            var contactId = packet.GetInt();

            // Check friend
            var friend = client.User.GetFriend(contactId);

            if (friend == null)
            {
                Log.Warning("FriendBlock: User '{0}' tried to block invalid friend.", client.User.AccountId);
                return;
            }

            // Check status
            if (friend.FriendshipStatus != FriendshipStatus.Normal)
            {
                Send.FriendBlockR(client.User, false, contactId);
                return;
            }

            // Change status
            friend.FriendshipStatus = FriendshipStatus.Blocked;
            MsgrServer.Instance.Database.SetFriendshipStatusOneSided(client.User.Id, contactId, friend.FriendshipStatus);

            Send.FriendBlockR(client.User, true, contactId);

            // Live update
            var friendUser = MsgrServer.Instance.UserManager.Get(contactId);

            if (friendUser != null)
            {
                // Show as offline from now on
                Send.FriendOffline(friendUser, client.User);
            }
        }
コード例 #3
0
ファイル: MsgrHandlers.cs プロジェクト: anjhony6778/aura
        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, status);
                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);

            // 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);
            }
        }