Example #1
0
 /// <summary>
 /// Send array of outcome friendship requests to user.
 /// </summary>
 /// <param name="user">user.</param>
 /// <exception cref="ConnectionInterruptedException"></exception>
 private void SendOutcomeFriendshipRequests(OnlineUser user)
 {
     user.Client.SendMessage(new OutcomeFriendshipRequestsMessage
     {
         Logins = DBoperations.GetOutcomeFriendshipRequests(user.Id)
     });
 }
Example #2
0
        /// <summary>
        /// Send array of all users to user.
        /// </summary>
        /// <param name="user">user.</param>
        /// <exception cref="ConnectionInterruptedException"></exception>
        private void SendAllUsers(OnlineUser user)
        {
            string[] allUsers        = DBoperations.GetAllUsers();
            string[] incomeRequests  = DBoperations.GetIncomeFriendshipRequests(user.Id);
            string[] outcomeRequests = DBoperations.GetOutcomeFriendshipRequests(user.Id);
            string[] friends         = DBoperations.GetFriends(user.Id);

            string[] users = allUsers.Where(x =>
                                            !incomeRequests.Contains(x) &
                                            !outcomeRequests.Contains(x) &
                                            !friends.Contains(x) &
                                            x != user.Login).ToArray();

            string[] online_users = onlineUsers.Select(x => x.Login).ToArray();

            user.Client.SendMessage(new AllUsersMessage
            {
                OnlineUsers  = users.Where(x => online_users.Contains(x)).ToArray(),
                OfflineUsers = users.Where(x => !online_users.Contains(x)).ToArray()
            });
        }