From 6fe79a8f65f96c08946c36607428c8c5790c1f33 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Mon, 27 Apr 2015 12:03:47 +0300 Subject: Allow using XHR for client to server requests and websockets for push (#12518) Change-Id: I6a9cc8f97d7e3578bf7aa9ce512d042ab637494e --- server/src/com/vaadin/ui/PushConfiguration.java | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'server') diff --git a/server/src/com/vaadin/ui/PushConfiguration.java b/server/src/com/vaadin/ui/PushConfiguration.java index 90ad28542c..22941ea5ae 100644 --- a/server/src/com/vaadin/ui/PushConfiguration.java +++ b/server/src/com/vaadin/ui/PushConfiguration.java @@ -139,6 +139,33 @@ public interface PushConfiguration extends Serializable { */ public void setParameter(String parameter, String value); + /** + * Sets whether to force the use of XHR when sending data from the client to + * the server. + * + * This settings currently only has effect when using websockets, which by + * default send client to server requests through the websockets channel. If + * you need to support cookies, HTTP auth or similar features not available + * in websockets communication you can set this to true. + * + * @since 7.6 + * @param alwaysUseXhrForServerRequests + * true to always use XHR for server requests, false otherwise + */ + public void setAlwaysUseXhrForServerRequests( + boolean alwaysUseXhrForServerRequests); + + /** + * Checks whether to force the use of XHR when sending data from the client + * to the server. + * + * @see #setAlwaysUseXhrForServerRequests(boolean) + * + * @since 7.6 + * @return true to always use XHR for server requests, false otherwise + */ + public boolean isAlwaysUseXhrForServerRequests(); + } class PushConfigurationImpl implements PushConfiguration { @@ -291,4 +318,14 @@ class PushConfigurationImpl implements PushConfiguration { .keySet()); } + @Override + public void setAlwaysUseXhrForServerRequests( + boolean alwaysUseXhrForServerRequests) { + getState().alwaysUseXhrForServerRequests = alwaysUseXhrForServerRequests; + } + + @Override + public boolean isAlwaysUseXhrForServerRequests() { + return getState(false).alwaysUseXhrForServerRequests; + } } -- cgit v1.2.3