[load] one place server ping

This commit is contained in:
magenoxx 2012-05-04 22:49:04 +04:00
parent a17f8e6059
commit 1c0b807a02
8 changed files with 61 additions and 8 deletions

View file

@ -51,6 +51,8 @@ public interface MageServer {
public boolean setUserData(String userName, String sessionId, UserDataView userDataView) throws MageException;
public ServerState getServerState() throws MageException;
public boolean ping(String sessionId) throws MageException;
//table methods
public TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;

View file

@ -57,6 +57,8 @@ public interface Session {
boolean isConnected();
boolean ping();
String[] getPlayerTypes();
List<GameTypeView> getGameTypes();

View file

@ -1090,6 +1090,21 @@ public class SessionImpl implements Session {
public void setEmbeddedMageServerAction(Action embeddedMageServerAction) {
this.embeddedMageServerAction = embeddedMageServerAction;
}
@Override
public boolean ping() {
try {
if (isConnected()) {
server.ping(sessionId);
}
return true;
} catch (MageException ex) {
handleMageException(ex);
} catch (Throwable t) {
handleThrowable(t);
}
return false;
}
}
class MageAuthenticator extends Authenticator {