forked from External/mage
added client/server ping + remove inactive connections from server
This commit is contained in:
parent
774d56dd6b
commit
ab599dd335
7 changed files with 105 additions and 20 deletions
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.server;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.logging.Level;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.Deck;
|
||||
|
|
@ -50,6 +51,7 @@ public class Session {
|
|||
private String username;
|
||||
private int messageId = 0;
|
||||
private String ackMessage;
|
||||
private long lastPing;
|
||||
private final CallbackServerSession callback = new CallbackServerSession();
|
||||
|
||||
public Session(String userName, UUID clientId) {
|
||||
|
|
@ -137,4 +139,12 @@ public class Session {
|
|||
return username;
|
||||
}
|
||||
|
||||
public void ping() {
|
||||
this.lastPing = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean stillAlive() {
|
||||
return (System.currentTimeMillis() - lastPing) < 60000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue