Java Code Examples for org.eclipse.jetty.websocket.api.RemoteEndpoint#flush()
The following examples show how to use
org.eclipse.jetty.websocket.api.RemoteEndpoint#flush() .
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: WebsocketServerInitiatedPingTest.java From knox with Apache License 2.0 | 6 votes |
@Override public void onWebSocketConnect(Session sess) { super.onWebSocketConnect(sess); try { Thread.sleep(1000); } catch (Exception e) { } final String textMessage = "PingPong"; final ByteBuffer binaryMessage = ByteBuffer.wrap( textMessage.getBytes(StandardCharsets.UTF_8)); try { RemoteEndpoint remote = getRemote(); remote.sendPing(binaryMessage); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException x) { throw new RuntimeIOException(x); } }
Example 2
Source File: BadSocket.java From knox with Apache License 2.0 | 6 votes |
@Override public void onWebSocketBinary(byte[] payload, int offset, int len) { if (isNotConnected()) { return; } try { RemoteEndpoint remote = getRemote(); remote.sendBytes(BufferUtil.toBuffer(payload, offset, len), null); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException x) { throw new RuntimeIOException(x); } }
Example 3
Source File: EchoSocket.java From knox with Apache License 2.0 | 6 votes |
@Override public void onWebSocketBinary(byte[] payload, int offset, int len) { if (isNotConnected()) { return; } try { RemoteEndpoint remote = getRemote(); remote.sendBytes(BufferUtil.toBuffer(payload, offset, len), null); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException x) { throw new RuntimeIOException(x); } }
Example 4
Source File: EchoSocket.java From knox with Apache License 2.0 | 6 votes |
@Override public void onWebSocketText(String message) { if (isNotConnected()) { return; } try { RemoteEndpoint remote = getRemote(); remote.sendString(message, null); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException x) { throw new RuntimeIOException(x); } }
Example 5
Source File: WebsocketServerInitiatedMessageTest.java From knox with Apache License 2.0 | 5 votes |
@Override public void onWebSocketConnect(Session sess) { super.onWebSocketConnect(sess); try { RemoteEndpoint remote = getRemote(); remote.sendString("echo", null); if (remote.getBatchMode() == BatchMode.ON) { remote.flush(); } } catch (IOException x) { throw new RuntimeIOException(x); } }