![JAR search and dependency download from the Maven repository](/logo.png)
io.socket.client.AckWithTimeOut Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of socket.io-client Show documentation
Show all versions of socket.io-client Show documentation
Socket.IO Client Library for Java
The newest version!
package io.socket.client;
import java.util.Timer;
import java.util.TimerTask;
public abstract class AckWithTimeOut implements Ack {
private Timer timer;
private long timeOut = 0;
private boolean called = false;
public AckWithTimeOut() {
}
public AckWithTimeOut(long timeout_after) {
if (timeout_after <= 0)
return;
this.timeOut = timeout_after;
startTimer();
}
private void startTimer() {
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
callback(new NoAck());
}
}, timeOut);
}
void resetTimer() {
if (timer != null) {
timer.cancel();
startTimer();
}
}
void cancelTimer() {
if (timer != null)
timer.cancel();
}
void callback(Object... args) {
if (called) return;
called = true;
cancelTimer();
call(args);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy