TooTallNate / Java-WebSocket

A barebones WebSocket client and server implementation written in 100% Java.
http://tootallnate.github.io/Java-WebSocket
MIT License
10.47k stars 2.57k forks source link

Blocking until response returned. #1417

Closed nd185084 closed 3 months ago

nd185084 commented 3 months ago

Is there a way to block after sending message untill response is accepted from other side? In such case, is it possible to get the response object as well?

java version "22.0.1" 2024-04-16 Java(TM) SE Runtime Environment (build 22.0.1+8-16) Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

org.java-websocket version 1.5.6

PhilipRoman commented 3 months ago

There are lots of ways to implement this, here is one example using BlockingQueue: https://github.com/TooTallNate/Java-WebSocket/issues/1246#issuecomment-1129648585

Also some more discussion here: https://github.com/TooTallNate/Java-WebSocket/issues/1037