Skip to content

Commit 611d897

Browse files
committed
Added reconnectBlocking overload that supports timeout in WebSocketClient.java
1 parent c69b298 commit 611d897

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/java/org/java_websocket/client/WebSocketClient.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,20 @@ public boolean reconnectBlocking() throws InterruptedException {
327327
return connectBlocking();
328328
}
329329

330+
/**
331+
* Same as <code>reconnect</code> but blocks with a timeout until the websocket connected or failed
332+
* to do so.<br>
333+
*
334+
* @param timeout The connect timeout
335+
* @param timeUnit The timeout time unit
336+
* @return Returns whether it succeeded or not.
337+
* @throws InterruptedException Thrown when the threads get interrupted
338+
*/
339+
public boolean reconnectBlocking(long timeout, TimeUnit timeUnit) throws InterruptedException {
340+
reset();
341+
return connectBlocking(timeout, timeUnit);
342+
}
343+
330344
/**
331345
* Reset everything relevant to allow a reconnect
332346
*

0 commit comments

Comments
 (0)