Java Code Examples for com.vaadin.util.CurrentInstance#get()

The following examples show how to use com.vaadin.util.CurrentInstance#get() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SockJSPushHandler.java    From vertx-vaadin with MIT License 6 votes vote down vote up
private void onConnect(SockJSSocket sockJSSocket) {
    RoutingContext routingContext = CurrentInstance.get(RoutingContext.class);

    String uuid = sockJSSocket.writeHandlerID();
    connectedSocketsLocalMap.put(uuid, sockJSSocket);
    PushSocket socket = new PushSocketImpl(sockJSSocket);

    initSocket(sockJSSocket, routingContext, socket);

    // Send an ACK
    socket.send("ACK-CONN|" + uuid);

    sessionHandler.handle(new SockJSRoutingContext(routingContext, rc ->
        callWithUi(new PushEvent(socket, routingContext, null), establishCallback)
    ));
}
 
Example 2
Source File: VaadinScope.java    From jdal with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
public String getConversationId() {
	Integer uiId = null;
	
	UI ui =  UI.getCurrent();
	if (ui == null) {
		UIid id = CurrentInstance.get(UIid.class);
		if (id != null) {
			uiId = id.getUiId();
		}
	}
	else if (ui != null) {
		if (!sessions.containsKey(ui)) {
			ui.addDetachListener(this);
			sessions.put(ui, VaadinSession.getCurrent().getSession().getId());
		}

		uiId = ui.getUIId();
	}
	
	return uiId != null ? getConversationId(uiId) : null;
}