Java Code Examples for javax.websocket.RemoteEndpoint.Basic#setBatchingAllowed()
The following examples show how to use
javax.websocket.RemoteEndpoint.Basic#setBatchingAllowed() .
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: TesterFirehoseServer.java From Tomcat8-Source-Read with MIT License | 5 votes |
@OnMessage public void onMessage(Session session, String msg) throws IOException { if (started) { return; } synchronized (this) { if (started) { return; } else { started = true; } } System.out.println("Received " + msg + ", now sending data"); session.getUserProperties().put( org.apache.tomcat.websocket.Constants.BLOCKING_SEND_TIMEOUT_PROPERTY, Long.valueOf(SEND_TIME_OUT_MILLIS)); Basic remote = session.getBasicRemote(); remote.setBatchingAllowed(true); for (int i = 0; i < MESSAGE_COUNT; i++) { remote.sendText(MESSAGE); if (i % (MESSAGE_COUNT * 0.4) == 0) { remote.setBatchingAllowed(false); remote.setBatchingAllowed(true); } } // Flushing should happen automatically on session close session.close(); }
Example 2
Source File: TesterFirehoseServer.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@OnMessage public void onMessage(Session session, String msg) throws IOException { if (started) { return; } synchronized (this) { if (started) { return; } else { started = true; } } System.out.println("Received " + msg + ", now sending data"); session.getUserProperties().put( "org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT", Long.valueOf(SEND_TIME_OUT_MILLIS)); Basic remote = session.getBasicRemote(); remote.setBatchingAllowed(true); for (int i = 0; i < MESSAGE_COUNT; i++) { remote.sendText(MESSAGE); if (i % (MESSAGE_COUNT * 0.4) == 0) { remote.setBatchingAllowed(false); remote.setBatchingAllowed(true); } } // Flushing should happen automatically on session close session.close(); }
Example 3
Source File: TesterFirehoseServer.java From tomcatsrc with Apache License 2.0 | 5 votes |
@OnMessage public void onMessage(Session session, String msg) throws IOException { if (started) { return; } synchronized (this) { if (started) { return; } else { started = true; } } System.out.println("Received " + msg + ", now sending data"); session.getUserProperties().put( "org.apache.tomcat.websocket.BLOCKING_SEND_TIMEOUT", Long.valueOf(SEND_TIME_OUT_MILLIS)); Basic remote = session.getBasicRemote(); remote.setBatchingAllowed(true); for (int i = 0; i < MESSAGE_COUNT; i++) { remote.sendText(MESSAGE); if (i % (MESSAGE_COUNT * 0.4) == 0) { remote.setBatchingAllowed(false); remote.setBatchingAllowed(true); } } // Flushing should happen automatically on session close session.close(); }