Java Code Examples for java.net.http.WebSocket#request()
The following examples show how to use
java.net.http.WebSocket#request() .
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: ClientEndpoint.java From conga with Apache License 2.0 | 5 votes |
public CompletionStage<?> onBinary(WebSocket webSocket, ByteBuffer src, boolean last) { if (src.hasRemaining()) { BufferSupply bufferSupply = ringBuffer.get(); bufferSupply.acquireAndCopy(src); bufferSupply.release(); } webSocket.request(1); // Returning null indicates normal completion return null; }
Example 2
Source File: ClientEndpoint.java From conga with Apache License 2.0 | 5 votes |
public CompletionStage<?> onText(WebSocket webSocket, CharSequence message, boolean last) { if (message.length() > 0) { BufferSupply bufferSupply = ringBuffer.get(); ByteBuffer buffer = bufferSupply.acquire(); String str = message.toString(); byte [] src = str.getBytes(); buffer.put(src); bufferSupply.release(); } webSocket.request(1); return null; }
Example 3
Source File: CatnipShardImpl.java From catnip with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onOpen(final WebSocket webSocket) { for(final Extension extension : catnip.extensionManager().extensions()) { for(final CatnipHook hook : extension.hooks()) { hook.rawGatewayOpenHook(shardInfo); } } webSocket.request(1); }
Example 4
Source File: WebSocketConnection.java From triplea with GNU General Public License v3.0 | 5 votes |
@Override public void onOpen(final WebSocket webSocket) { synchronized (queuedMessages) { client = webSocket; connectionIsOpen = true; queuedMessages.forEach( message -> client .sendText(message, true) .exceptionally(logWebSocketError(Level.SEVERE, "Failed to send queued text."))); queuedMessages.clear(); } // Allow onText to be called at least once, WebSocketConnection is initialized webSocket.request(1); }
Example 5
Source File: WebSocketConnection.java From triplea with GNU General Public License v3.0 | 5 votes |
@Override public CompletionStage<?> onText( final WebSocket webSocket, final CharSequence data, final boolean last) { // No need to synchronize access, this listener is never called concurrently // and always called in-order by the API textAccumulator.append(data); if (last) { listener.messageReceived(textAccumulator.toString()); textAccumulator.setLength(0); } // We're done processing, allow listener to be called again at least once webSocket.request(1); return null; }
Example 6
Source File: ClientEndpoint.java From conga with Apache License 2.0 | 4 votes |
public void onOpen(WebSocket webSocket) { webSocket.request(1); }