/** * Queue an event. * * @param event Event to queue. */ public synchronized void queue(Event event) { Assert.isTrue(event.getPage() == page, () -> "Event does not belong to this queue's page"); queue.add(event); if (queue.size() == 1 && (!ExecutionContext.isProcessing() || ExecutionContext.getPage() != page)) { Session session = page.getSession(); if (session != null) { session.ping("flush"); } } }
/** * Invoke a callback in the execution context of the specified page. * * @param pid The id of the page. * @param callback The callback to invoke. */ public static void invoke(String pid, Runnable callback) { Page page = PageRegistry.getPage(pid); Page current = getPage(); Assert.isTrue(current == null || current == page, () -> "Cannot switch current page execution context"); try { if (current == null) { clear(); put(ExecutionContext.ATTR_REQUEST, new ClientRequest(page.getSession(), Collections.emptyMap())); } callback.run(); } finally { if (current == null) { destroy(); } } }
@Override public void handleRequest(ClientRequest request) { WebSocketSession socket = request.getPage().getSession().getSocket(); String id = request.getParam("id", String.class); String channel = request.getParam("channel", String.class);
@Override public void afterInitialized(BaseComponent root) { super.afterInitialized(root); page = root.getPage(); session = page.getSession(); noAutoLock = page.getAttribute(ATTR_NO_AUTO_LOCK, false); timeoutWindow = (BaseUIComponent) root; getEventManager().subscribe(SessionControl.EVENT_ROOT, applicationControlListener); IUser user = securityService.getAuthenticatedUser(); lblLocked.setLabel(user == null ? null : Mode.BASELINE.getLabel(TIMEOUT_EXPIRATION, user.getFullName() + "@" + user.getSecurityDomain().getName())); setMode(Mode.BASELINE); session.addSessionListener(sessionListener); }