예제 #1
0
        public void SearchUserTest()
        {
            Authentification.AuthentificationService a = new Authentification.AuthentificationService();
            a.SetupAuth();
            a.SignupUser(new Utility.Network.Users.CryptedCredentials("User1", "abc"));

            var getuser = UsersInfos.SearchUser("User1");

            Assert.AreEqual(true, getuser[0].Name == "User1");
            Assert.AreEqual(true, getuser[0].UID == "abc");
        }
예제 #2
0
        public void Handle(Request request, Socket socket)
        {
            switch (request.RequestsType)
            {
            case RequestsTypes.Search:
                Console.WriteLine("Request by client :" + (request as RequestSearch).Name);
                MusicsManagement.ClientSearch.SearchAnswer.Do(request as RequestSearch, socket);
                break;

            case RequestsTypes.MusicsBinaries:
                if (Indexation.TryGetMusicByID((request as RequestBinairies).RequestedBinaries.MID, out Music m))
                {
                    Music answer = new Music(m.Title, new Author(m.Author.Name), m.Album, Indexation.GetFileBinary(m))
                    {
                        Format = m.Format,
                        Rating = m.Rating
                    };
                    new RequestAnswer(answer).Send(socket);
                }
                break;

            case RequestsTypes.Favorites:
                List <Music> tmp = UsersInfos.GetLikedMusics((request as RequestFavorites).UserID);
                new RequestAnswer(tmp).Send(socket);
                break;

            case RequestsTypes.Users:
                if (Program.MyServer.Clients.GetUser(socket).Rank != Rank.Viewer)
                {
                    new RequestAnswer(UsersInfos.SearchUser((request as RequestUser).Username), true).Send(socket);
                }
                else
                {
                    new RequestAnswer(null, false).Send(socket);
                }
                break;
            }
        }