feat(multiplayer): join request should be cancelled when user operation time out.

This commit is contained in:
huanghongxun
2021-10-10 00:36:59 +08:00
parent eedcff785e
commit 877c5a827c
4 changed files with 92 additions and 47 deletions

View File

@@ -359,17 +359,21 @@ public final class Lang {
private static Timer timer;
public static synchronized TimerTask setTimeout(Runnable runnable, long delayMs) {
public static synchronized Timer getTimer() {
if (timer == null) {
timer = new Timer();
}
return timer;
}
public static synchronized TimerTask setTimeout(Runnable runnable, long delayMs) {
TimerTask task = new TimerTask() {
@Override
public void run() {
runnable.run();
}
};
timer.schedule(task, delayMs);
getTimer().schedule(task, delayMs);
return task;
}