diff options
author | Artur Signell <artur@vaadin.com> | 2013-06-05 14:27:09 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2013-06-05 15:14:42 +0300 |
commit | edca4095d2e75d73f9d6a5acb2da9009129b4db2 (patch) | |
tree | 15226365a8501ba55255dc21111696709aafa632 /client | |
parent | ebd4a5c0ae6e61c20283ba5b866fe51e3576a179 (diff) | |
download | vaadin-framework-edca4095d2e75d73f9d6a5acb2da9009129b4db2.tar.gz vaadin-framework-edca4095d2e75d73f9d6a5acb2da9009129b4db2.zip |
Allow customizing client-side push config on server side (#11867)
Change-Id: I212067aa0bd04e3e73844ef57963b5622291986a
Diffstat (limited to 'client')
4 files changed, 20 insertions, 9 deletions
diff --git a/client/src/com/vaadin/client/ApplicationConnection.java b/client/src/com/vaadin/client/ApplicationConnection.java index a3279e5631..ac058b5536 100644 --- a/client/src/com/vaadin/client/ApplicationConnection.java +++ b/client/src/com/vaadin/client/ApplicationConnection.java @@ -95,6 +95,7 @@ import com.vaadin.shared.communication.LegacyChangeVariablesInvocation; import com.vaadin.shared.communication.MethodInvocation; import com.vaadin.shared.communication.SharedState; import com.vaadin.shared.ui.ui.UIConstants; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; /** * This is the client side communication "engine", managing client-server @@ -3359,9 +3360,11 @@ public class ApplicationConnection { * <code>false</code> to disable the push connection. */ public void setPushEnabled(boolean enabled) { + final PushConfigurationState pushState = uIConnector.getState().pushConfiguration; + if (enabled && push == null) { push = GWT.create(PushConnection.class); - push.init(this, new CommunicationErrorHandler() { + push.init(this, pushState, new CommunicationErrorHandler() { @Override public boolean onError(String details, int statusCode) { showCommunicationError(details, statusCode); @@ -3378,7 +3381,7 @@ public class ApplicationConnection { * the old connection to disconnect, now is the right time * to open a new connection */ - if (uIConnector.getState().pushMode.isEnabled()) { + if (pushState.mode.isEnabled()) { setPushEnabled(true); } diff --git a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java index 997e84145c..f7936f8717 100644 --- a/client/src/com/vaadin/client/communication/AtmospherePushConnection.java +++ b/client/src/com/vaadin/client/communication/AtmospherePushConnection.java @@ -30,6 +30,7 @@ import com.vaadin.client.VConsole; import com.vaadin.shared.ApplicationConstants; import com.vaadin.shared.communication.PushConstants; import com.vaadin.shared.ui.ui.UIConstants; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; /** * The default {@link PushConnection} implementation that uses Atmosphere for @@ -133,15 +134,22 @@ public class AtmospherePushConnection implements PushConnection { * (non-Javadoc) * * @see - * com.vaadin.client.communication.PushConenction#init(com.vaadin.client - * .ApplicationConnection) + * com.vaadin.client.communication.PushConnection#init(ApplicationConnection + * , Map<String, String>, CommunicationErrorHandler) */ @Override public void init(final ApplicationConnection connection, + final PushConfigurationState pushConfiguration, CommunicationErrorHandler errorHandler) { this.connection = connection; this.errorHandler = errorHandler; + config = createConfig(); + for (String param : pushConfiguration.parameters.keySet()) { + config.setStringValue(param, + pushConfiguration.parameters.get(param)); + } + runWhenAtmosphereLoaded(new Command() { @Override public void execute() { @@ -216,9 +224,6 @@ public class AtmospherePushConnection implements PushConnection { } protected AtmosphereConfiguration getConfig() { - if (config == null) { - config = createConfig(); - } return config; } diff --git a/client/src/com/vaadin/client/communication/PushConnection.java b/client/src/com/vaadin/client/communication/PushConnection.java index a4a3bbc0cc..bc2af98f1a 100644 --- a/client/src/com/vaadin/client/communication/PushConnection.java +++ b/client/src/com/vaadin/client/communication/PushConnection.java @@ -19,6 +19,7 @@ package com.vaadin.client.communication; import com.google.gwt.user.client.Command; import com.vaadin.client.ApplicationConnection; import com.vaadin.client.ApplicationConnection.CommunicationErrorHandler; +import com.vaadin.shared.ui.ui.UIState.PushConfigurationState; /** * Represents the client-side endpoint of a bidirectional ("push") communication @@ -39,6 +40,7 @@ public interface PushConnection { * The ApplicationConnection */ public void init(ApplicationConnection connection, + PushConfigurationState pushConfigurationState, CommunicationErrorHandler errorHandler); /** diff --git a/client/src/com/vaadin/client/ui/ui/UIConnector.java b/client/src/com/vaadin/client/ui/ui/UIConnector.java index 1c2c6ddeb8..45b0a7ab9d 100644 --- a/client/src/com/vaadin/client/ui/ui/UIConnector.java +++ b/client/src/com/vaadin/client/ui/ui/UIConnector.java @@ -644,8 +644,9 @@ public class UIConnector extends AbstractSingleComponentContainerConnector configurePolling(); } - if (stateChangeEvent.hasPropertyChanged("pushMode")) { - getConnection().setPushEnabled(getState().pushMode.isEnabled()); + if (stateChangeEvent.hasPropertyChanged("pushConfiguration")) { + getConnection().setPushEnabled( + getState().pushConfiguration.mode.isEnabled()); } if (stateChangeEvent.hasPropertyChanged("overlayContainerLabel")) { |