Exemplo n.º 1
0
        /// <summary>
        /// Let this user's friends know that he has just logged in. Also lets
        /// the user know that his friends are online.
        /// </summary>
        /// <param name="user">The user.</param>
        private void NotifyFriends(Actor user)
        {
            DataTable friends     = Lib.dbService.Actor.GetFriendsList(user["shortname"].ToString());
            int       friendCount = 0;
            string    friendNames = "";

            foreach (DataRow row in friends.Rows)
            {
                if ((bool)row["IsAuthorised"])
                {
                    Actor friendUser = Lib.Checkonline(row["FriendName"].ToString());
                    if (friendUser != null)
                    {
                        friendUser.SendAlertGood(user["shortname"] + " has just logged on.\r\n");
                        friendCount++;
                        friendNames += friendUser["shortname"] + ", ";
                    }
                }
            }

            // Are any of this user's friends online?
            if (friendCount > 0)
            {
                // Remove the last ", "
                friendNames = friendNames.Remove(friendNames.Length - 2, 2);
                user.SendAlertGood(friendCount + " friend(s) online: " + friendNames + "\r\n");
            }
        }