Created
November 14, 2016 05:15
-
-
Save abhirockzz/6efef2084f7dcf632e8345de009b385c to your computer and use it in GitHub Desktop.
WebSocket time out using (java.util.concurrent) Future
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.... | |
public void broadcast(Session s, String msg){ | |
RemoteEndpoint asyncHandle = s.getRemoteAsync(); | |
asyncHandle.setSendTimeout(2000); //2000 ms | |
Future<Void> tracker = asyncHandle.sendText(msg); //will timeout after 2 seconds | |
tracker.get(); //will throw java.util.ExecutionException if the process had timed out | |
} | |
.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment