Package fr.cesi.chat.domain

Examples of fr.cesi.chat.domain.User


    }
  }

  @Override
  public void run() {
    User user = null;
    try {
      // Affiche les messages reçus
      while (true) {
        user = (User) in.readObject();
View Full Code Here


    // on utilise notre fonction
    Statut statut = Statut.EN_LIGNE;
    Message message1 = new Message();
    message1.setMessage("comment vas-tu?");
    message1.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message1.setUserTo("florian");
    Gson gson = new Gson();
    String json = gson.toJson(message1);
    MessagesHistoryMongo conect;
    conect = new MessagesHistoryMongo();
View Full Code Here

 
   
    Statut statut = Statut.EN_LIGNE;
    Message message1 = new Message();
    message1.setMessage("comment vas-tu?");
    message1.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message1.setUserTo("florian");
   
   
    Gson gson = new Gson();
    String json1 = gson.toJson(message1);
    conect.saveMessage(json1);
   
    Statut statut2 = Statut.ABSENT;
    Message message2 = new Message();
    message2.setMessage("bien et toi");
    message2.setUserFrom(new User("florian", statut2, "192.168.1.2"));
    message2.setUserTo("Benoit");
   
    Gson gson2 = new Gson();
    String json2 = gson2.toJson(message2);
    conect.saveMessage(json2);
   
    Message message3 = new Message();
    message3.setMessage("cool raoul");
    message3.setUserFrom(new User("antho", statut, "192.168.1.3"));
    message3.setUserTo("All");
   
    Gson gson3 = new Gson();
    String json3 = gson3.toJson(message3);
    conect.saveMessage(json3);
   
    Message message4 = new Message();
    message4.setMessage("on se fait un mac DO");
    message4.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message4.setUserTo("florian");
   
    Gson gson4 = new Gson();
    String json4 = gson4.toJson(message4);
    conect.saveMessage(json4);
   
    Message message5 = new Message();
    message5.setMessage("ou un kebab");
    message5.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message5.setUserTo("all");
   
    Gson gson5 = new Gson();
    String json5 = gson5.toJson(message5);
    conect.saveMessage(json5);
   
    Message message6 = new Message();
    message6.setMessage("pour moi mc do c'est cool!");
    message6.setUserFrom(new User("antho", statut, "192.168.1.3"));
    message6.setUserTo("all");
   
    Gson gson6 = new Gson();
    String json6 = gson6.toJson(message6);
    conect.saveMessage(json6);
   
    Message message7 = new Message();
    message7.setMessage("bon ben mc do");
    message7.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message7.setUserTo("all");
   
    Gson gson7 = new Gson();
    String json7 = gson7.toJson(message7);
    conect.saveMessage(json7);

    Message message8 = new Message();
    message8.setMessage("on prend quelle voiture?");
    message8.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message8.setUserTo("all");
   
    Gson gson8 = new Gson();
    String json8 = gson8.toJson(message8);
    conect.saveMessage(json8);
   
    Message message9 = new Message();
    message9.setMessage("la mienne c'est bon");
    message9.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message9.setUserTo("all");
   
    Gson gson9 = new Gson();
    String json9 = gson9.toJson(message9);
    conect.saveMessage(json9);
   
    Message message10 = new Message();
    message10.setMessage("allez go en B");
    message10.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message10.setUserTo("all");
   
    Gson gson10 = new Gson();
    String json10 = gson10.toJson(message10);
    conect.saveMessage(json10);
   
    DBCollection messagesCollection = chatDatabase.getCollection("historymessages");
    Long numberOfMessages = messagesCollection.count();
   
    Assert.assertEquals(new Long(10) , numberOfMessages);
   
    Message message11 = new Message();
    message11.setMessage("un best OF!");
    message11.setUserFrom(new User("antho", statut, "192.168.1.3"));
    message11.setUserTo("all");
   
    Gson gson11 = new Gson();
    String json11 = gson11.toJson(message11);
    conect.saveMessage(json11);
View Full Code Here

    new Thread(clientThreadServerSendUsers).start();

  }

  public Client(String ipServeur, String utilisateur) throws IOException {
    User user = new User(utilisateur, Statut.EN_LIGNE, null);

    // MESSAGE
    // Pour l'envoie de message
    clientThreadServerResponseMessage = new ClientThreadServerResponseMessage(ipServeur);
    new Thread(clientThreadServerResponseMessage).start();
View Full Code Here

     * Quand je reçois un message avec l'evenement pour changer de nom d'utilisateur je parcours la liste des utilisateurs, supprime l'ancien et rajoute le nouveau
     */
    if (Event.CHANGING_STATUS_USERNAME == msgReceived.getEvent()) {
      Iterator<User> iterator = server.getUsers().iterator();
      while (iterator.hasNext()) {
        User user = iterator.next();
        String username = msgReceived.getUserFrom().getNickname();
        if (username.equals(user.getNickname())) {
          server.getUsers().remove(user);
          server.getUsers().add(new User(username, msgReceived.getUserFrom().getStatut(), msgReceived.getUserFrom().getIp()));
          server.sendUsers(server.getUsers());
          // msgReceived = new Message(Utils.getDateNow(), userServer, null, username + " est passé " + user.getStatut().getLibelle(), Evenement.SERVER);
        }
      }
    }

    /*
     * Quand je reçois un message avec l'evenement pour changer de nom d'utilisateur je parcours la liste des utilisateurs, supprime l'ancien et rajoute le nouveau
     */
    if (Event.CHANGING_USERNAME == msgReceived.getEvent()) {
      Iterator<User> iterator = server.getUsers().iterator();
      while (iterator.hasNext()) {
        User user = iterator.next();
        String[] usernames = msgReceived.getUserFrom().getNickname().split(",");
        String oldUsername = usernames[0];
        String username = usernames[1];
        if (oldUsername.equals(user.getNickname())) {
          server.getUsers().remove(user);
          server.getUsers().add(new User(username, msgReceived.getUserFrom().getStatut(), msgReceived.getUserFrom().getIp()));
          server.sendUsers(server.getUsers());
          msgReceived = new Message(Utils.getDateNow(), userServer, null, oldUsername + " a changé en " + username, Event.SERVER);
        }
      }
    }

    // Si on reçoit l'évenement deleting username
    // on parcours la liste
    if (Event.DELETING_USERNAME == msgReceived.getEvent()) {
      Iterator<User> iterator = server.getUsers().iterator();
      while (iterator.hasNext()) {
        User user = iterator.next();
        if (msgReceived.getUserFrom().getNickname().equals(user.getNickname())) {
          msgReceived = new Message(Utils.getDateNow(), userServer, null, user.getNickname() + " s'est déconnecté.", Event.SERVER);
          iterator.remove();
          server.sendUsers(server.getUsers());
          break;
        }
      }
View Full Code Here

  public void insert10Messages() {
    MessagesHistoryMongo conect = new MessagesHistoryMongo();
    Statut statut = Statut.EN_LIGNE;
    Message message1 = new Message();
    message1.setMessage("comment vas-tu?");
    message1.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message1.setUserTo("florian");
    message1.setEvent(Event.ALL_CLIENTS);
    message1.setDate(new Date(1394743482).toString());

    conect.saveMessage(message1);

    Statut statut2 = Statut.ABSENT;
    Message message2 = new Message();
    message2.setMessage("bien et toi");
    message2.setUserFrom(new User("florian", statut2, "192.168.1.2"));
    message2.setUserTo("Benoit");
    message2.setEvent(Event.ONE_CLIENT);
    message2.setDate(new Date(1394829882).toString());
 

    conect.saveMessage(message2);

    Message message3 = new Message();
    message3.setMessage("cool raoul");
    message3.setUserFrom(new User("antho", statut, "192.168.1.3"));
    message3.setUserTo("All");
    message3.setEvent(Event.ALL_CLIENTS);
    message3.setDate(new Date(1394916282).toString());

    conect.saveMessage(message3);

    Message message4 = new Message();
    message4.setMessage("on se fait un mac DO");
    message4.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message4.setUserTo("florian");
    message4.setEvent(Event.ALL_CLIENTS);
    message4.setDate(new Date(1395002682).toString());

    conect.saveMessage(message4);

    Message message5 = new Message();
    message5.setMessage("ou un kebab");
    message5.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message5.setUserTo("all");
    message5.setEvent(Event.ALL_CLIENTS);
    message5.setDate(new Date(1395089082).toString());

    conect.saveMessage(message5);

    Message message6 = new Message();
    message6.setMessage("pour moi mc do c'est cool!");
    message6.setUserFrom(new User("antho", statut, "192.168.1.3"));
    message6.setUserTo("all");
    message6.setEvent(Event.ALL_CLIENTS);
    message6.setDate(new Date(1395175482).toString());

    conect.saveMessage(message6);

    Message message7 = new Message();
    message7.setMessage("bon ben mc do");
    message7.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message7.setUserTo("all");
    message7.setEvent(Event.ALL_CLIENTS);
    message7.setDate(new Date(1395261882).toString());

    conect.saveMessage(message7);

    Message message8 = new Message();
    message8.setMessage("on prend quelle voiture?");
    message8.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message8.setUserTo("all");
    message8.setEvent(Event.ALL_CLIENTS);
    message8.setDate(new Date(1395348282).toString());

    conect.saveMessage(message8);

    Message message9 = new Message();
    message9.setMessage("la mienne c'est bon");
    message9.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message9.setUserTo("all");
    message9.setEvent(Event.ALL_CLIENTS);
    message9.setDate(new Date(1395434682).toString());
   
    conect.saveMessage(message9);

    Message message10 = new Message();
    message10.setMessage("allez go en B! on va les avoir");
    message10.setUserFrom(new User("florian", statut, "192.168.1.2"));
    message10.setUserTo("all");
    message10.setEvent(Event.ALL_CLIENTS);
    message10.setDate(new Date(1395521082).toString());
   
    conect.saveMessage(message10);
View Full Code Here

    // on utilise notre fonction
    Statut statut = Statut.EN_LIGNE;
    Message message1 = new Message();
    message1.setMessage("comment vas-tu?");
    message1.setUserFrom(new User("benoit", statut, "192.168.1.1"));
    message1.setUserTo("florian");
    message1.setEvent(Event.ALL_CLIENTS);
    message1.setDate(new Date().toString());
    MessagesHistoryMongo conect;
    conect = new MessagesHistoryMongo();
View Full Code Here

    Assert.assertEquals(new Long(10), numberOfMessages);
    Assert.assertEquals(new Date(1394743482).toString(),messages.get(0).getDate());
   
    Message message11 = new Message();
    message11.setMessage("un best OF!");
    message11.setUserFrom(new User("antho", Statut.EN_LIGNE, "192.168.1.3"));
    message11.setUserTo("all");
    message11.setEvent(Event.ALL_CLIENTS);
    message11.setDate(new Date(1395621082).toString());

    conect.saveMessage(message11);
View Full Code Here

    // On set le nouveau nickname dans la variable global user
    String ip = user.getIp();
    String nickanme = user.getNickname();
    Statut statut = user.getStatut();
    user = new User();
    user.setIp(ip);
    user.setNickname(newNickname);
    user.setStatut(statut);
    return user;
  }
View Full Code Here

  User postUpdateStatusUser(@RequestBody final User userUpdated, ModelAndView model) {
    Message message = new Message(Utils.getDateNow(), userUpdated, "", null, Event.CHANGING_STATUS_USERNAME);
    clientService.sendMessage(output, message);
    // On set le nouveau nickname dans la variable global user
    user.setStatut(userUpdated.getStatut());
    return new User(user.getNickname(), user.getStatut(), user.getIp());
  }
View Full Code Here

TOP

Related Classes of fr.cesi.chat.domain.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.