Skip to content

Commit

Permalink
update game listings to use full beacons
Browse files Browse the repository at this point in the history
  • Loading branch information
ColaColin committed Oct 9, 2014
1 parent 75a628f commit 3ac7fc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/info/nanodesu/rest/GamesListing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ object GamesListing extends RestHelper with Loggable with RefreshRunner {
override val RUN_INTERVAL = 3 * 1000
val processName = "games listing service"

case class Game(name: String, id: String, ip: String, port: String, lastAvailable: Long)
case class Game(beacon: String, version: String, id: String, ip: String, port: String, lastAvailable: Long)

var games = List[Game]()
val mutex = new Object()

def runQuery() = mutex synchronized {
games = games.filter(_.lastAvailable - System.currentTimeMillis() > -15000);
games = games.filter(_.lastAvailable - System.currentTimeMillis() > -7000);
}

case class ListMessage(name: String, ip: String, port: String, id: String)
case class ListMessage(beacon: String, version: String, ip: String, port: String, id: String)
object ListMessage {
def apply(in: JValue): Box[ListMessage] = Helpers.tryo(in.extract[ListMessage])
def unapply(in: JValue): Option[ListMessage] = apply(in)
Expand All @@ -51,7 +51,7 @@ object GamesListing extends RestHelper with Loggable with RefreshRunner {
case "addServer" :: Nil JsonPost ListMessage(data) -> _ =>
mutex synchronized {
games = games.filter(_.id != data.id)
games = Game(data.name, data.id, data.ip, data.port, System.currentTimeMillis()) :: games
games = Game(data.beacon, data.version, data.id, data.ip, data.port, System.currentTimeMillis()) :: games
}

OkResponse()
Expand Down

0 comments on commit 3ac7fc5

Please sign in to comment.