diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/communication/PushConnection.java | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/client/src/com/vaadin/client/communication/PushConnection.java b/client/src/com/vaadin/client/communication/PushConnection.java index 0731d513ea..e3d2e576e6 100644 --- a/client/src/com/vaadin/client/communication/PushConnection.java +++ b/client/src/com/vaadin/client/communication/PushConnection.java @@ -42,7 +42,7 @@ public class PushConnection { private boolean connected = false; - private AtmosphereConfiguration config = createConfig(); + private AtmosphereConfiguration config; public PushConnection() { } @@ -72,7 +72,10 @@ public class PushConnection { } } - protected JavaScriptObject getConfig() { + protected AtmosphereConfiguration getConfig() { + if (config == null) { + config = createConfig(); + } return config; } @@ -102,8 +105,8 @@ public class PushConnection { */ protected void onTransportFailure() { VConsole.log("Push connection using primary method (" - + config.getTransport() + ") failed. Trying with " - + config.getFallbackTransport()); + + getConfig().getTransport() + ") failed. Trying with " + + getConfig().getFallbackTransport()); } /** @@ -112,7 +115,8 @@ public class PushConnection { * */ protected void onError() { - VConsole.error("Push connection using " + config.getTransport() + VConsole.error("Push connection using " + + getConfig().getTransport() + " failed!"); } @@ -126,11 +130,21 @@ public class PushConnection { return this[key]; }-*/; + protected final native void setStringValue(String key, String value) + /*-{ + this[key] = value; + }-*/; + protected final native int getIntValue(String key) /*-{ return this[key]; }-*/; + protected final native void setIntValue(String key, int value) + /*-{ + this[key] = value; + }-*/; + } public static class AtmosphereConfiguration extends AbstractJSO { @@ -146,6 +160,14 @@ public class PushConnection { public final String getFallbackTransport() { return getStringValue("fallbackTransport"); } + + public final void setTransport(String transport) { + setStringValue("transport", transport); + } + + public final void setFallbackTransport(String fallbackTransport) { + setStringValue("fallbackTransport", fallbackTransport); + } } public static class AtmosphereResponse extends AbstractJSO { @@ -172,7 +194,7 @@ public class PushConnection { } - private static native AtmosphereConfiguration createConfig() + protected native AtmosphereConfiguration createConfig() /*-{ return { transport: 'websocket', |