diff --git a/WebContent/js/cah.constants.js b/WebContent/js/cah.constants.js index 6dfaa90..af0d1a0 100644 --- a/WebContent/js/cah.constants.js +++ b/WebContent/js/cah.constants.js @@ -62,6 +62,7 @@ cah.$.AjaxResponse.CONNECTED_AT = "ca"; cah.$.AjaxResponse.WHITE_CARDS = "wc"; cah.$.AjaxResponse.HAND = "h"; cah.$.AjaxResponse.ERROR_CODE = "ec"; +cah.$.AjaxResponse.SERVER_STARTED = "SS"; cah.$.AjaxResponse.NEXT = "next"; cah.$.AjaxResponse.GAME_INFO = "gi"; cah.$.AjaxResponse.ERROR = "e"; @@ -226,6 +227,7 @@ cah.$.GameInfo = function() { }; cah.$.GameInfo.prototype.dummyForAutocomplete = undefined; cah.$.GameInfo.GAME_OPTIONS = "go"; +cah.$.GameInfo.CREATED = "gca"; cah.$.GameInfo.PLAYERS = "P"; cah.$.GameInfo.SPECTATORS = "V"; cah.$.GameInfo.HOST = "H"; diff --git a/src/main/java/net/socialgamer/cah/Constants.java b/src/main/java/net/socialgamer/cah/Constants.java index 3cd41f7..7ac2ec4 100644 --- a/src/main/java/net/socialgamer/cah/Constants.java +++ b/src/main/java/net/socialgamer/cah/Constants.java @@ -301,6 +301,8 @@ public class Constants { @DuplicationAllowed @GoDataType("int") SERIAL(AjaxRequest.SERIAL), + @GoDataType("int64") + SERVER_STARTED("SS"), @GoDataType("[]int") WHITE_CARDS("wc"); @@ -735,6 +737,8 @@ public class Constants { */ @GoStruct public enum GameInfo { + @GoDataType("int64") + CREATED("gca"), HOST("H"), @DuplicationAllowed @GoDataType("int") diff --git a/src/main/java/net/socialgamer/cah/data/Game.java b/src/main/java/net/socialgamer/cah/data/Game.java index 320b052..d9bfe39 100644 --- a/src/main/java/net/socialgamer/cah/data/Game.java +++ b/src/main/java/net/socialgamer/cah/data/Game.java @@ -112,6 +112,7 @@ public class Game { private final GameOptions options = new GameOptions(); private final Set cardcastDeckIds = Collections.synchronizedSet(new HashSet()); private final Metrics metrics; + private final long created = System.currentTimeMillis(); private int judgeIndex = 0; @@ -536,6 +537,7 @@ public class Game { if (null == host) { return null; } + info.put(GameInfo.CREATED, created); info.put(GameInfo.HOST, host.getUser().getNickname()); info.put(GameInfo.STATE, state.toString()); info.put(GameInfo.GAME_OPTIONS, options.serialize(includePassword)); diff --git a/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java b/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java index 0dccf72..626dbba 100644 --- a/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java +++ b/src/main/java/net/socialgamer/cah/handlers/FirstLoadHandler.java @@ -24,6 +24,7 @@ package net.socialgamer.cah.handlers; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -40,6 +41,7 @@ import com.google.inject.Provider; import net.socialgamer.cah.CahModule.BanList; import net.socialgamer.cah.CahModule.IncludeInactiveCardsets; +import net.socialgamer.cah.CahModule.ServerStarted; import net.socialgamer.cah.Constants.AjaxOperation; import net.socialgamer.cah.Constants.AjaxResponse; import net.socialgamer.cah.Constants.CardSetData; @@ -66,13 +68,16 @@ public class FirstLoadHandler extends Handler { private final Set banList; private final Session hibernateSession; private final Provider includeInactiveCardsetsProvider; + private final Date serverStarted; @Inject public FirstLoadHandler(final Session hibernateSession, @BanList final Set banList, - @IncludeInactiveCardsets final Provider includeInactiveCardsetsProvider) { + @IncludeInactiveCardsets final Provider includeInactiveCardsetsProvider, + @ServerStarted final Date serverStarted) { this.banList = banList; this.hibernateSession = hibernateSession; this.includeInactiveCardsetsProvider = includeInactiveCardsetsProvider; + this.serverStarted = serverStarted; } @Override @@ -123,6 +128,7 @@ public class FirstLoadHandler extends Handler { } finally { hibernateSession.close(); } + ret.put(AjaxResponse.SERVER_STARTED, serverStarted.getTime()); return ret; }