/** * Returns the desktop from the given websocket session. * * @param wsession websocket session * @return a desktop, null if desktop not found */ public static Desktop getDesktop(Session wsession) { org.zkoss.zk.ui.Session session = (org.zkoss.zk.ui.Session) wsession.getUserProperties() .get(ZKWebSocket.class.getName()); if (session == null) throw new IllegalStateException("ZK Session cannot be null!"); List<String> dtids = wsession.getRequestParameterMap().get("dtid"); if (dtids.isEmpty()) throw new IllegalStateException("the value of the key with 'dtid' cannot be null!"); DesktopCache desktopCache = ((SessionCtrl) session).getDesktopCache(); return desktopCache != null ? desktopCache.getDesktopIfAny(dtids.get(0)) : null; } }
/** Returns the desktop of the specified ID, or null if not found. * If null is returned, {@link #recoverDesktop} will be invoked. * @param sess the session (never null) * @param dtid the desktop ID to look for * @since 5.0.3 */ protected Desktop getDesktop(Session sess, String dtid) { return ((WebAppCtrl) sess.getWebApp()).getDesktopCache(sess).getDesktopIfAny(dtid); }
.getDesktopCache(sess).getDesktopIfAny(dtid); if (desktop == null) { response.setHeader("ZK-Comet-Error", "Desktop not found, "+dtid);