public void createUser()
        {
            //Receive the datas from the client side
            MessageUser user = (MessageUser)Net.receiveMessage(comm.GetStream());


            //Add the client to the tab
            users.Add(new User(users.Count + 1, user.Login, user.Password));


            //Update the file of users
            UserSerialize us = new UserSerialize(users);

            us.SerializeNow();

            //Print the users created
            Console.WriteLine("Table users updated : ");

            foreach (User u in users)
            {
                Console.WriteLine(u.Login + " " + u.Password);
            }
            Console.WriteLine("\n");

            //Relaunche the menu when finish creation
            launchApp();
        }
Exemple #2
0
        public Server(int port)
        {
            this.port = port;
            userTcps  = new Dictionary <User, List <TcpClient> >();

            //Users of our app
            users = new List <User>();

            //Object to serialize users.txt
            UserSerialize us = new UserSerialize(users);

            //Deserialize users from the file users.txt
            users = us.DeSerializeNow();

            //User that are connected
            connectedUsers = new List <User>();


            /* Creation of private chats */
            List <Conversation> conversationsPrivate1 = new List <Conversation>();

            conversationsPrivate1.Add(new Conversation("Salut", users[1]));
            conversationsPrivate1.Add(new Conversation("Bonjour", users[2]));


            List <User> privateChatParticipants = new List <User>();

            privateChatParticipants.Add(users[1]);
            privateChatParticipants.Add(users[2]);

            PrivateChat privateChat1 = new PrivateChat(1, "Private Chat with " + users[1].Login + " and " + users[2].Login, 2, conversationsPrivate1, privateChatParticipants);


            privateChats = new List <PrivateChat>();
            privateChats.Add(privateChat1);



            /* Creation of topics */
            List <Conversation> conversationsTopic1 = new List <Conversation>();

            conversationsTopic1.Add(new Conversation("Salut message 1", users[1]));
            conversationsTopic1.Add(new Conversation("Bonjour", users[2]));

            List <Conversation> conversationsTopic2 = new List <Conversation>();

            conversationsTopic2.Add(new Conversation("Hello hello", users[1]));
            conversationsTopic2.Add(new Conversation("Test test", users[2]));


            List <User> participants = new List <User>();

            participants.Add(users[1]);
            participants.Add(users[2]);


            topics = new List <Topic>();
            Topic topic1 = new Topic(1, "Le topic du PC !", users[1], 2, conversationsTopic1, participants);
            Topic topic2 = new Topic(2, "Le topic du Console", users[2], 2, conversationsTopic2, participants);

            /* End of creation topics */


            topics.Add(topic1);
            topics.Add(topic2);
        }