Ejemplo n.º 1
0
 private void updateUserList() {
   List<String> usernames = new ArrayList<>();
   for (Session s : session.getOpenSessions()) {
     String uname = (String) s.getUserProperties().get(USERNAME_KEY);
     usernames.add(uname);
   }
   this.endpointConfig.getUserProperties().put(USERNAMES_KEY, usernames);
 }
Ejemplo n.º 2
0
 private void broadcastUserListUpdate() {
   UserListUpdateMessage ulum = new UserListUpdateMessage(this.getUserList());
   for (Session nextSession : session.getOpenSessions()) {
     try {
       nextSession.getBasicRemote().sendObject(ulum);
     } catch (IOException | EncodeException ex) {
       System.out.println("Error updating a client : " + ex.getMessage());
     }
   }
 }
Ejemplo n.º 3
0
  private void broadcastTranscriptUpdate() {
    String v = this.transcript.getRec();
    String g;
    if (c.equals(v)) {
      for (Session nextSession : session.getOpenSessions()) {

        ChatUpdateMessage cdm =
            new ChatUpdateMessage(
                this.transcript.getLastUsername(),
                this.transcript.getLastMessage(),
                this.transcript.getRec());

        try {
          nextSession.getBasicRemote().sendObject(cdm);
        } catch (IOException | EncodeException ex) {
          System.out.println("Error updating a client : " + ex.getMessage());
        }
      }
    } else {
      for (Session nextSession : session.getOpenSessions()) {
        String check = this.transcript.getRec();
        ChatUpdateMessage cdm =
            new ChatUpdateMessage(
                this.transcript.getLastUsername(),
                this.transcript.getLastMessage(),
                this.transcript.getRec());
        g = (String) nextSession.getUserProperties().get(USERNAME_KEY);
        if (v.equals(g)) {
          try {
            nextSession.getBasicRemote().sendObject(cdm);
          } catch (IOException | EncodeException ex) {
            System.out.println("Error updating a client : " + ex.getMessage());
          }
        }
      }
    }
  }