/** * Returns the broadcast queue for the given OpenCms session id.<p> * * @param sessionId the OpenCms session id to get the broadcast queue for * * @return the broadcast queue for the given OpenCms session id */ public Buffer getBroadcastQueue(String sessionId) { CmsSessionInfo sessionInfo = getSessionInfo(getSessionUUID(sessionId)); if (sessionInfo == null) { // return empty message buffer if the session is gone or not available return BufferUtils.synchronizedBuffer(new CircularFifoBuffer(CmsSessionInfo.QUEUE_SIZE)); } return sessionInfo.getBroadcastQueue(); }
/** * Returns the broadcast queue for the given OpenCms session id.<p> * * @param sessionId the OpenCms session id to get the broadcast queue for * * @return the broadcast queue for the given OpenCms session id */ public Buffer getBroadcastQueue(String sessionId) { CmsSessionInfo sessionInfo = getSessionInfo(getSessionUUID(sessionId)); if (sessionInfo == null) { // return empty message buffer if the session is gone or not available return BufferUtils.synchronizedBuffer(new CircularFifoBuffer(CmsSessionInfo.QUEUE_SIZE)); } return sessionInfo.getBroadcastQueue(); }
/** * Sends a broadcast to all sessions of a given user.<p> * * The user sending the message may be a real user like * <code>cms.getRequestContext().currentUser()</code> or * <code>null</code> for a system message.<p> * * @param fromUser the user sending the broadcast * @param message the message to broadcast * @param toUser the target (receiver) of the broadcast */ public void sendBroadcast(CmsUser fromUser, String message, CmsUser toUser) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(fromUser, message); List<CmsSessionInfo> userSessions = getSessionInfos(toUser.getId()); Iterator<CmsSessionInfo> i = userSessions.iterator(); // send the broadcast to all sessions of the selected user while (i.hasNext()) { CmsSessionInfo sessionInfo = i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
/** * Sends a broadcast to all sessions of a given user.<p> * * The user sending the message may be a real user like * <code>cms.getRequestContext().currentUser()</code> or * <code>null</code> for a system message.<p> * * @param fromUser the user sending the broadcast * @param message the message to broadcast * @param toUser the target (receiver) of the broadcast */ public void sendBroadcast(CmsUser fromUser, String message, CmsUser toUser) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(fromUser, message); List userSessions = getSessionInfos(toUser.getId()); Iterator i = userSessions.iterator(); // send the broadcast to all sessions of the selected user while (i.hasNext()) { CmsSessionInfo sessionInfo = (CmsSessionInfo)i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
/** * Sends a broadcast to all sessions of all currently authenticated users.<p> * * @param cms the OpenCms user context of the user sending the broadcast * * @param message the message to broadcast */ public void sendBroadcast(CmsObject cms, String message) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(cms.getRequestContext().currentUser(), message); // send the broadcast to all authenticated sessions Iterator i = m_sessionStorageProvider.getAll().iterator(); while (i.hasNext()) { CmsSessionInfo sessionInfo = (CmsSessionInfo)i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
/** * Sends a broadcast to all sessions of all currently authenticated users.<p> * * @param cms the OpenCms user context of the user sending the broadcast * * @param message the message to broadcast */ public void sendBroadcast(CmsObject cms, String message) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // create the broadcast CmsBroadcast broadcast = new CmsBroadcast(cms.getRequestContext().getCurrentUser(), message); // send the broadcast to all authenticated sessions Iterator<CmsSessionInfo> i = m_sessionStorageProvider.getAll().iterator(); while (i.hasNext()) { CmsSessionInfo sessionInfo = i.next(); if (m_sessionStorageProvider.get(sessionInfo.getSessionId()) != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(broadcast); } } }
Buffer queue = info.getBroadcastQueue(); if (!queue.isEmpty()) { StringBuffer broadcasts = new StringBuffer();
/** * Sends a broadcast to the specified user session.<p> * * @param cms the OpenCms user context of the user sending the broadcast * * @param message the message to broadcast * @param sessionId the OpenCms session uuid target (receiver) of the broadcast */ public void sendBroadcast(CmsObject cms, String message, String sessionId) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // send the broadcast only to the selected session CmsSessionInfo sessionInfo = m_sessionStorageProvider.get(new CmsUUID(sessionId)); if (sessionInfo != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(new CmsBroadcast(cms.getRequestContext().currentUser(), message)); } }
/** * Sends a broadcast to the specified user session.<p> * * @param cms the OpenCms user context of the user sending the broadcast * * @param message the message to broadcast * @param sessionId the OpenCms session uuid target (receiver) of the broadcast */ public void sendBroadcast(CmsObject cms, String message, String sessionId) { if (CmsStringUtil.isEmptyOrWhitespaceOnly(message)) { // don't broadcast empty messages return; } // send the broadcast only to the selected session CmsSessionInfo sessionInfo = m_sessionStorageProvider.get(new CmsUUID(sessionId)); if (sessionInfo != null) { // double check for concurrent modification sessionInfo.getBroadcastQueue().add(new CmsBroadcast(cms.getRequestContext().getCurrentUser(), message)); } }