Java Code Examples for com.vaadin.client.WidgetUtil#stringify()
The following examples show how to use
com.vaadin.client.WidgetUtil#stringify() .
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: SockJSPushConnection.java From vertx-vaadin with MIT License | 6 votes |
@Override public void push(JsonObject message) { if (!isBidirectional()) { throw new IllegalStateException( "This server to client push connection should not be used to send client to server messages"); } if (state == State.OPEN) { String messageJson = WidgetUtil.stringify(message); getLogger().info("Sending push (" + transport + ") message to server: " + messageJson); doPush(socket, messageJson); return; } if (state == State.CONNECTING) { getConnectionStateHandler().pushNotConnected(message); return; } throw new IllegalStateException("Can not push after disconnecting"); }
Example 2
Source File: XhrConnection.java From flow with Apache License 2.0 | 6 votes |
/** * Sends an asynchronous UIDL request to the server using the given URI. * * @param payload * The URI to use for the request. May includes GET parameters */ public void send(JsonObject payload) { XhrResponseHandler responseHandler = createResponseHandler(); responseHandler.setPayload(payload); responseHandler.setRequestStartTime(Profiler.getRelativeTimeMillis()); String payloadJson = WidgetUtil.stringify(payload); XMLHttpRequest xhr = Xhr.post(getUri(), payloadJson, JsonConstants.JSON_CONTENT_TYPE, responseHandler); Console.log("Sending xhr message to server: " + payloadJson); if (webkitMaybeIgnoringRequests && BrowserInfo.get().isWebkit()) { final int retryTimeout = 250; new Timer() { @Override public void run() { // Use native js to access private field in Request if (resendRequest(xhr) && webkitMaybeIgnoringRequests) { // Schedule retry if still needed schedule(retryTimeout); } } }.schedule(retryTimeout); } }
Example 3
Source File: AtmospherePushConnection.java From flow with Apache License 2.0 | 5 votes |
@Override public void push(JsonObject message) { if (!isBidirectional()) { throw new IllegalStateException( "This server to client push connection should not be used to send client to server messages"); } if (state == State.CONNECTED) { String messageJson = WidgetUtil.stringify(message); Console.log("Sending push (" + transport + ") message to server: " + messageJson); if (transport.equals("websocket")) { FragmentedMessage fragmented = new FragmentedMessage( messageJson); while (fragmented.hasNextFragment()) { doPush(socket, fragmented.getNextFragment()); } } else { doPush(socket, messageJson); } return; } if (state == State.CONNECT_PENDING) { getConnectionStateHandler().pushNotConnected(message); return; } throw new IllegalStateException("Can not push after disconnecting"); }