From: <fza...@us...> - 2005-11-30 22:04:39
|
Update of /cvsroot/struts/ajaxchat/WEB-INF/src/org/apache/struts/apps/ajaxchat/dto In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13448/WEB-INF/src/org/apache/struts/apps/ajaxchat/dto Modified Files: RoomDTO.java UserDTO.java Log Message: Index: RoomDTO.java =================================================================== RCS file: /cvsroot/struts/ajaxchat/WEB-INF/src/org/apache/struts/apps/ajaxchat/dto/RoomDTO.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RoomDTO.java 29 Nov 2005 23:08:30 -0000 1.1 --- RoomDTO.java 30 Nov 2005 22:04:28 -0000 1.2 *************** *** 32,36 **** * This class is a Data Transfer Object (DTO) that describes a Room. Note that * a few of the methods here do just a tad more than I would generally like in ! * a DAO, but the architecture made sense this way, so I went with it. * * @author <a href="mailto:fza...@om...">Frank W. Zammetti</a>. --- 32,36 ---- * This class is a Data Transfer Object (DTO) that describes a Room. Note that * a few of the methods here do just a tad more than I would generally like in ! * a DTO, but the architecture made sense this way, so I went with it. * * @author <a href="mailto:fza...@om...">Frank W. Zammetti</a>. *************** *** 128,132 **** public void addUser(UserDTO inUser) { ! log.info("RoomDTO addUser()..."); boolean userAlreadyInRoom = false; for (Iterator it = users.iterator(); it.hasNext();) { --- 128,132 ---- public void addUser(UserDTO inUser) { ! log.debug("RoomDTO addUser()..."); boolean userAlreadyInRoom = false; for (Iterator it = users.iterator(); it.hasNext();) { *************** *** 141,145 **** Collections.sort(users); } - log.info("User added to room"); } // End addUser(). --- 141,144 ---- *************** *** 153,157 **** public void removeUser(UserDTO inUser) { ! log.info("RoomDTO removeUser()..."); // Scan through all users until we find the one with the username of the // user passed in and remove the user from the list. --- 152,156 ---- public void removeUser(UserDTO inUser) { ! log.debug("RoomDTO removeUser()..."); // Scan through all users until we find the one with the username of the // user passed in and remove the user from the list. *************** *** 162,166 **** UserDTO user = (UserDTO)it.next(); if (user.getUsername().equalsIgnoreCase(usernameToRemove)) { ! log.info("Found " + usernameToRemove + ", removing..."); indexToRemove = i; } --- 161,165 ---- UserDTO user = (UserDTO)it.next(); if (user.getUsername().equalsIgnoreCase(usernameToRemove)) { ! log.info("Found " + usernameToRemove + ", removing"); indexToRemove = i; } *************** *** 169,175 **** if (indexToRemove != -1) { users.remove(indexToRemove); - log.info(usernameToRemove + " removed"); } - log.info("RoomDTO removeUser() Done"); } // End removeUser(). --- 168,172 ---- *************** *** 185,189 **** public Vector getMessages(Date inDateTime) { ! log.info("RoomDTO getMessages()..."); // Scan through the list of messages for the room and find any that were // posted after the given datetime, add those to a list to return. --- 182,186 ---- public Vector getMessages(Date inDateTime) { ! log.debug("RoomDTO getMessages()..."); // Scan through the list of messages for the room and find any that were // posted after the given datetime, add those to a list to return. *************** *** 192,196 **** MessageDTO message = (MessageDTO)it.next(); if (message.getPostedDateTime().after(inDateTime)) { ! log.info("Returning message : " + message); al.add(message); } --- 189,193 ---- MessageDTO message = (MessageDTO)it.next(); if (message.getPostedDateTime().after(inDateTime)) { ! log.debug("Returning message: " + message); al.add(message); } Index: UserDTO.java =================================================================== RCS file: /cvsroot/struts/ajaxchat/WEB-INF/src/org/apache/struts/apps/ajaxchat/dto/UserDTO.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** UserDTO.java 29 Nov 2005 23:08:30 -0000 1.1 --- UserDTO.java 30 Nov 2005 22:04:28 -0000 1.2 *************** *** 20,23 **** --- 20,24 ---- import java.lang.reflect.Field; + import java.util.Date; *************** *** 37,40 **** --- 38,52 ---- /** + * This stores the datetime of the last AJAX message received by this user, + * specifically for the getMessages request. When the user enters a room, + * this is set. When they leave the room, it is nulled. The + * UserClearerDaemonThread checks it and if it's not null, it sees if the + * value is older than it's threshold for determining if a user is inactive. + * If it is, the user is removed from all rooms. + */ + private Date lastAJAXRequest; + + + /** * Constructor. * *************** *** 73,76 **** --- 85,112 ---- /** + * Accessor for lastAJAXRequest field. + * + * @return Date Current value of lastAJAXRequest field. + */ + public Date getLastAJAXRequest() { + + return lastAJAXRequest; + + } // End getLastAJAXRequest(). + + + /** + * Mutator for lastAJAXRequest field. + * + * @param inLastAJAXRequest New value of lastAJAXRequest field. + */ + public void setLastAJAXRequest(Date inLastAJAXRequest) { + + lastAJAXRequest = inLastAJAXRequest; + + } // End setLastAJAXRequest(). + + + /** * Used to sort the list of users in the room when a new user joins. * |